Jump to content

Archived

This topic is now archived and is closed to further replies.

bradkenyon

php mail in html mail

Recommended Posts

I am using a script, that uses a pear library, I use to use the html mime mail library which did a great job w/ html email

 

I am wondering how I could set this email msg to be in html.

<?php
require_once "Mail.php";

$from = "email@domain.edu";
$to = "receiver@ domain.edu";
$subject = "Hi!";
$body = "<p>Hi, How are you?</p>";

$host = "mail1.domain.edu";
$username = "user";
$password = "pass";

$headers = array ('From' => $from,
'To' => $to,
'X-From-Web' => $from,
'Subject' => $subject);
$smtp = Mail::factory('smtp',
array ('host' => $host,
'auth' => true,
'username' => $username,
'password' => $password));

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

if(PEAR::isError($mail))
{
echo("<p>" . $mail->getMessage() . "</p>");
}
else
{
echo("<p>Message successfully sent!</p>");
}
?>

 

The email msg I receive, has the <p></p> tags in it.

 

Share this post


Link to post
Share on other sites

I am using a script, that uses a pear library, I use to use the html mime mail library which did a great job w/ html email

 

I am wondering how I could set this email msg to be in html.

<?php
require_once "Mail.php";

$from = "email@domain.edu";
$to = "receiver@ domain.edu";
$subject = "Hi!";
$body = "<p>Hi, How are you?</p>";

$host = "mail1.domain.edu";
$username = "user";
$password = "pass";

$headers = array ('From' => $from,
'To' => $to,
'X-From-Web' => $from,
'Subject' => $subject);
$smtp = Mail::factory('smtp',
array ('host' => $host,
'auth' => true,
'username' => $username,
'password' => $password));

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

if(PEAR::isError($mail))
{
echo("<p>" . $mail->getMessage() . "</p>");
}
else
{
echo("<p>Message successfully sent!</p>");
}
?>

 

The email msg I receive, has the <p></p> tags in it.

 

 

add this in your headers...

'MIME-Version: 1.0' . "\r\n";

'Content-type: text/html; charset=iso-8859-1' . "\r\n";

Share this post


Link to post
Share on other sites

I recommend reading this: http://www.hudzilla.org/phpbook/read.php/15_5_3

 

You want to use this command

 

<?php

include('Mail.php');

include('Mail\mime.php');

 

$message = new Mail_mime();

$html = "<p>Hey</p>";

$message->setHTMLBody($html);

 

$body = $message->get();

$extraheaders = array("From"=>"me@example.com", "Subject"=>"My Subject 7");

$headers = $message->headers($extraheaders);

 

$mail = Mail::factory("mail");

$mail->send("bob@bob.com", $headers, $body);

 

?>

Share this post


Link to post
Share on other sites

use phpemailler  class .it works very well abd u can download it on source forge.net

Share this post


Link to post
Share on other sites

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.