PEAR Forum :: PHP Extension and Application Repository

PEAR Forum Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
Problem with HTML mail ...

 
Post new topic   Reply to topic    PEAR Forum Forum Index -> Mail
View previous topic :: View next topic  
Author Message
Oliver77



Joined: 30 May 2009
Posts: 2

PostPosted: Sat May 30, 2009 8:57 am    Post subject: Problem with HTML mail ... Reply with quote

Hello,

I need your help ! I must send html mails with pear ... They are well sent, but their bodies are not in html ... The body is html code ...

I'm trying to solve this problem since a fews days without success ...

Thanks in advance for your help !

Here's my code :

Quote:

<?php
require_once( 'mime.php' );
require_once( 'Mail.php' );

$from = "MOI <[email protected]>";
$to = "TOI <[email protected]>";
$subject = "Essai Mail HTML avc PEAR";
$html = "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>
<html xmlns='http://www.w3.org/1999/xhtml'>
<head><meta http-equiv='Content-Type' content='text/html; charset=utf-8' /></head>
<body>Message en HTML</body>
</html>";

$host = "smtp.fai.fr";
$username = "monlogin";
$password = "monpwd";
$crlf = "\n";
$headers = array ('From' => $from,
'To' => $to,
'Subject' => $subject);

$mime = new Mail_Mime($crlf);
$mime->setHTMLBody($html);
print_r($html);

$body = $mime->get();
$hdrs = $mime->headers($hdrs);

$smtp =& Mail::factory('smtp',
array ('host' => $host,
'auth' => true,
'username' => $username,
'password' => $password));

$mail = $smtp->send($to, $headers, $body);
print_r($body);
?>
Back to top
View user's profile Send private message
Oliver77



Joined: 30 May 2009
Posts: 2

PostPosted: Sun May 31, 2009 6:30 pm    Post subject: [SOLVED] The solution to my problem ! Reply with quote

Hi,

So i finaly found my errors ...

Here's the code that works fine ... It may help someone ...

Code:
<?php
require_once( 'mime.php' );
require_once( 'Mail.php' );

$from = "MOI <[email protected]>";
$to = "TOI <[email protected]>";
$subject = "Essai Mail HTML avc PEAR";
$html = "<html>
<body>Message en HTML</body>
</html>";

$host = "smtp.fai.fr";
$username = "monlogin";
$password = "monpwd";
$crlf = "\n";
$hdrs = array ('From' => $from,
'To' => $to,
'Subject' => $subject);

$mime = new Mail_Mime($crlf);
$mime->setHTMLBody($html);
print_r($html);

$body = $mime->get();
$headers = $mime->headers($hdrs);

$smtp =& Mail::factory('smtp',
array ('host' => $host,
'auth' => true,
'username' => $username,
'password' => $password));

$mail = $smtp->send($to, $headers, $body);

?>
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    PEAR Forum Forum Index -> Mail All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



PEAR Forum topic RSS feed 
Powered by phpBB © 2001, 2005 phpBB Group

Provided by Ministry of Web developement

'Actiemonitor' online projectmanagement software