Hey all, I'm having trouble getting a mime compliant email sent. I'm hoping that someone can shed some light on where I'm going wrong.
I am passing into this function an HTML page along with a plain text section. The To: and Reply-To: are known, and don't have to be set, but could be passed in aswell. Basically I have the MIME returned to me and put it into a database, then I retrieve it and send it out via the mail() function.
mail($to,$sub,$m,$headers); // headers being returned from the function below.
I get the email, and it shows all of the headers as I would expect. I am also using OE to view the entire source and it comes through. I'm getting the whole base64 encoding, etc. But when I get it, there are no attachements and there is nothing in the body of the message. What the heck am I doing wrong? I've tried different encoding. I've changed my boundary function several times to see if something is messed up there and it isn't.
Thanks so much for the attention.
Here is my function:
function setMime($sent_from,$subject,$full_html,$plain_text)
{
$rn = "\r\n";
$date = date("D, j M Y H:i:s ",mktime()).timezone();
$message_id = "<".time()."@".$_SERVERNAME.">";
$headers .= "Message-ID: $message_id".$rn;
$headers .= "Date: $date".$rn;
$headers .= "From: $sent_from".$rn;
$headers .= "Subject: $subject".$rn;
$headers .= "To: ReplaceToHere".$rn;
$headers .= "Reply-To: [email]nobody@nobody.com[/email]".$rn;
$headers .= "MIME-Version: 1.0".$rn;
$headers .= "Content-Type: multipart/alternative; boundary=\"".mimeBoundary()."\"".$rn;
$headers .= "You have a non-MIME email reader.".$rn.$rn;
$headers .= $rn;
$headers .= mimeBoundary().$rn;
$headers .= "Content-Type: text/plain; charset=iso-8859-1".$rn;
$headers .= "Content-Transfer-Encoding: base64".$rn.$rn;
$headers .= chunk_split(base64_encode($plain_text)).$rn;
$headers .= mimeBoundary().$rn;
$headers .= "Content-Type: text/html; charset=iso-8859-1".$rn;
$headers .= "Content-Transfer-Encoding: base64".$rn.$rn;
$headers .= chunk_split(base64_encode($full_html)).$rn;
$headers .= mimeBoundary().$rn;
return $headers;
}