Jump to content

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.

 

Link to comment
https://forums.phpfreaks.com/topic/124510-php-mail-in-html-mail/
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";

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);

 

?>

  • 5 weeks later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.