 |
|
|
| View previous topic :: View next topic |
| Author |
Message |
Oliver77
Joined: 30 May 2009 Posts: 2
|
Posted: Sat May 30, 2009 8:57 am Post subject: Problem with HTML mail ... |
|
|
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 <me@fai.fr>";
$to = "TOI <toi@fai.fr>";
$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 |
|
 |
Oliver77
Joined: 30 May 2009 Posts: 2
|
Posted: Sun May 31, 2009 6:30 pm Post subject: [SOLVED] The solution to my problem ! |
|
|
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 <moi@fai.fr>";
$to = "TOI <toi@fai.fr.fr>";
$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 |
|
 |
boards
Joined: 26 Feb 2010 Posts: 1
|
Posted: Fri Feb 26, 2010 1:17 pm Post subject: |
|
|
we have a problem when sending the comments content via email to the users.y? _________________ mrsa infection
mrsa infection |
|
| Back to top |
|
 |
|
|
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
|
|