I am having a problem with a mail function.
The server I am working on is PHP Version 4.3.2.
For some strange reason, part of the time sending mail it will work, the other half of the time it will not.
When just using mail() it seems to work okay, I have been using this on other servers with absolutely no issue:
function send_mail($emailaddress, $fromname, $fromaddress, $emailsubject, $body) {
$eol="\r\n";
$mime_boundary=md5(time());
// Common Headers
$headers .= 'From: '.$fromname.'<'.$fromaddress.'>'.$eol;
$headers .= 'Reply-To: Dedicated Clothing<'.$fromaddress.'>'.$eol;
$headers .= 'Return-Path: Dedicated<'.$fromaddress.'>'.$eol; // these two to set reply address
$headers .= "Message-ID: <".$now." TheSystem@".$_SERVER['SERVER_NAME'].">".$eol;
$headers .= "X-Mailer: PHP v".phpversion().$eol; // These two to help avoid spam-filters
# Boundry for marking the split & Multitype Headers
$headers .= 'MIME-Version: 1.0\r\n'.$eol;
$headers .= "Content-Type: multipart/related; boundary=\"".$mime_boundary."\"".$eol;
//echo $headers;
$msg = "";
// Setup for text OR html
$msg .= "Content-Type: multipart/alternative".$eol;
// Text Version
$msg .= "--".$mime_boundary.$eol;
$msg .= "Content-Type: text/plain; charset=iso-8859-1".$eol;
$msg .= "Content-Transfer-Encoding: 8bit".$eol;
//$msg .= strip_tags(str_replace("<br>", "\n", $body)).$eol.$eol;
$msg .= $body.$eol.$eol;
// Finished
$msg .= "--".$mime_boundary."--".$eol.$eol; // finish with two eol's for better security.
echo $msg;
// echo "<br><br>$body";
// SEND THE EMAIL
ini_set(sendmail_from,$fromaddress); // the INI lines are to force the From Address to be used !
mail($emailaddress, $emailsubject, $msg, $headers);
ini_restore(sendmail_from);
} // end send_mail
any idea exactly what I am doing wrong here?
The email will always send, and the subject will go through, however it will not always display the message..
I am using this to call it (OO)
$body = "$email, You have been signed up for something.com TEST Account. \n\n";
$body .= "Please disregard this message. If you have recieved this message in error, then sorry.\n";
Misc::send_mail($email,$this->fromname,$this->fromaddress,"Your something.com Account",$body);
Any help would be apreciated...