Jump to content

[SOLVED] html mail?


ohdang888

Recommended Posts

maybe you need to set properly the headers of the mail function. Check the php manual, I copied this from there

 

// To send HTML mail, the Content-type header must be set
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

 

then pass $headers to the mail function call

Link to comment
https://forums.phpfreaks.com/topic/130713-solved-html-mail/#findComment-678330
Share on other sites

o'm using the mail tutorial on this site...

 

now i'm getting an error:

Warning: Invalid argument supplied for foreach() in /home/ky4obama/public_html/mail/Mail.php on line 123

Warning: Invalid argument supplied for foreach() in /home/ky4obama/public_html/mail/Mail.php on line 151

Failed to set sender: M [sMTP: Invalid response code received from server (code: 501, response: : sender address must contain a domain)]

 

It sent mail before, with just that headers as an array, so i guess the new headers is messing it up.... any ideas?

Thanks!

 

<?php
require_once "mail/Mail.php";

$host = "server1.freesitespace.net";
$username = " ";
$password = " ";

$from = " my newsletter email address ";
$to = "[email protected] ";
$subject = "subject";
$body = "<a href='http://www.google.com/'>Google</a><br><img href='http://www.google.com/intl/en_ALL/images/logo.gif'>";
$reply = " [email protected]";

$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= array("From" => $from, "To" => $to, "Subject" => $subject, "Reply-to" => $reply);
$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>";
}
?>

Link to comment
https://forums.phpfreaks.com/topic/130713-solved-html-mail/#findComment-678451
Share on other sites

Archived

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

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