Gena
Posts: 591
|
| Posted: 07/30/2009, 2:37 AM |
|
you try to send HTML type email. Some email clients understands this kind of email some other doesn't. To be correct in anyway you need to use boundary separator..
try following function:
function send_email($to, $fromaddr, $fromname, $subject, $message_text, $message_html = "")
{
$subject = preg_replace("/\nfrom\:.*?\n/i", "", $subject);
$subject = preg_replace("/\nbcc\:.*?\n/i", "", $subject);
$subject = preg_replace("/\ncc\:.*?\n/i", "", $subject);
$message_text = preg_replace("/\nfrom\:.*?\n/i", "", $message_text);
$message_text = preg_replace("/\nbcc\:.*?\n/i", "", $message_text);
$message_text = preg_replace("/\ncc\:.*?\n/i", "", $message_text);
$message_html = preg_replace("/\nfrom\:.*?\n/i", "", $message_html);
$message_html = preg_replace("/\nbcc\:.*?\n/i", "", $message_html);
$message_html = preg_replace("/\ncc\:.*?\n/i", "", $message_html);
// create additional_parameters - this ensures that the RETURN-PATH will be properly set
// saving the mail from being rejected by the destination mail server as spam
// known servers that reject if RETURN-PATH domain does not match the from domain include
// gmail, hotmail, aol, excite, yahoo, btinternet
// most spam killers will also regard emails with
$additional_parameters = "-f $fromaddr";
// create additional_headers
$headers = "From: $fromname <$fromaddr>\r\n";
// specify MIME version 1.0
$headers .= "MIME-Version: 1.0\r\n";
// deal with html messages
if($message_html != "")
{
// unique boundary
$boundary = md5(uniqid(time())); //uniqid("sometext");
// tell e-mail client this e-mail contains alternate versions
$headers .= "Content-Type: multipart/alternative; boundary = $boundary\r\n\r\n";
// plain text version of message
$body = "--$boundary\r\n";
$body .= "Content-Type: text/plain; charset=ISO-8859-1\r\n";
$body .= "Content-Transfer-Encoding: 7 bit\r\n\r\n";
$body .= $message_text."\r\n\r\n";
// HTML version of message
$body .= "--$boundary\r\n";
$body .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$body .= "Content-Transfer-Encoding: 7 bit\r\n\r\n";
$body .= $message_html."\r\n\r\n";
}
// deal with plain text only messages
if($message_html == "")
{
// tell e-mail client the content type
$headers .= "Content-type: text/plain; charset=iso-8859-1\n";
// the plain text message
$body = $message_text;
}
// send message
return mail($to, $subject, $body, $headers, $additional_parameters);
}
then you set all variable and send you email like
send_email($to, $from, $fromname, $subject, $message_text, $message_html);
_________________
Gena |