Hi guys i have been working on this mime email with pdf invoice attached for a while, sooo much trouble with it, and i always seem to have trouble with mime emails with attachments.
I have it working in Thunderbird (comes with attachment perfect) but in windows mail the pdf attachment comes thru as a .txt which means all the content in garble
the mail setup is as follows and below is the output txt file in windows mail (i have omited about 10000 lines of garble in the middle )
also if anyone knows of a good written explaination of mime headers, a link would be awesome, every thing i read is soooo different
Thanx in advance
$attachment = chunk_split(base64_encode($stream));
$to = $pf['email'];
$subject = 'Your Invoice';
$random_hash = md5(date('r', time()));
$headers = "From: ".SITE_NOREPLY." \r\n";
$headers .= "Reply-To: ".SITE_EMAIL." \r\n";
$headers .= "\r\nContent-Type: multipart/mixed; boundary=\"PHP-mixed-".$random_hash."\"";
$message = "
--PHP-mixed-". $random_hash ."
Content-Type: multipart/alternative; boundary=\"PHP-alt-". $random_hash ."\"
--PHP-alt-". $random_hash ."
Content-Type: text/plain; charset=\"iso-8859-1\"
Content-Transfer-Encoding: 7bit
Hi $name
Please find Attached your most recent Invoice that is ready for payment
--PHP-alt-". $random_hash ."
Content-Type: text/html; charset=\"iso-8859-1\"
Content-Transfer-Encoding: 7bit
<h2>Invoice</h2>
<p>Attached Is the Invoice for Your Latest Order From Company</p>
--PHP-alt-". $random_hash ."
--PHP-mixed-". $random_hash ."
Content-Type: application/pdf; name=\"invoice-".$invid.".pdf\"
Content-Transfer-Encoding: base64
Content-Disposition: attachment
".$attachment."[code]
--PHP-mixed-". $random_hash ." --
";
mail( $to, $subject, $message, $headers );
[/code]
The ouput in windows mail is "att0042.txt"
--PHP-mixed-1783d3a01d99ae0a0bfafb11ad40cc94
Content-Type: application/pdf; name="invoice-2500.pdf"
Content-Transfer-Encoding: base64
Content-Disposition: attachment
JVBERi0xLjcKMyAwIG9iago8PC9UeXBlIC9QYWdlCi9QYXJlbnQgMSAwIFIKL01lZGlhQm94IFsw
IDAgNTk1LjI4IDg0MS44OV0KL1Jlc291cmNlcyAyIDAgUgovQW5ub3RzIFsKPDwvVHlwZSAvQW5u
b3QgL1N1YnR5cGUgL0xpbmsgL1JlY3QgWzU2LjY5IDc5OS4zNyAyODMuNDYgNzA4LjY2XSAvQ29u
dGVudHMgKP7/AGgAdAB0AHAAOgAvAC8AdwB3AHcALgBnAGEAdABlAC0AcwB5AHMAdABlAG0AcwAu
mUgMjEKL1Jvb3QgMjAgMCBSCi9JbmZvIDE5IDAgUgo+PgpzdGFydHhyZWYKNzA5NTQyCiUlRU9GC
g==
--PHP-mixed-1783d3a01d99ae0a0bfafb11ad40cc94 --