Re: Email Attatchments PDF
What have you got so far? MIME with Base64 encoding (not quoted printable) is the way to do it. I usually use a boundary generated from an SHA1 of the current time and a few dashes which will never appear in Base64.
Re: Email Attatchments PDF
Sorry for delay...
PHP Code:
$to = $rowSupplier['printer_email'];
$subject = 'Purchase Order';
$bound_text = time();
$bound = "--".$bound_text."\r\n";
$bound_last = "--".$bound_text."--\r\n";
$headers = "From: [email protected]\r\n";
$headers .= "MIME-Version: 1.0\r\n"
."Content-Type: multipart/mixed; boundary=\"$bound_text\"";
$message = "If you can see this MIME than your client doesn't accept MIME types!\r\n" .$bound;
$message .= "Content-Type: text/plain; charset=\"iso-8859-1\"\r\n"
."Content-Transfer-Encoding: 7bit\r\n\r\n"
. $body
."\r\n"
.$bound;
$file = file_get_contents("PO/$orderNumber.pdf");
$message .= "Content-Type: application/pdf; name=\"$orderNumber.pdf\"\r\n"
."Content-Transfer-Encoding: base64\r\n"
."Content-disposition: attachment; file=\"$orderNumber.pdf\"\r\n"
."\r\n"
.chunk_split(base64_encode($file))
.$bound_last;
mail($to, $subject, $message, $headers);
if($rowSupplier['email2']!="")
{
mail($rowSupplier['email2'], $subject, $message, $headers);
}
mail("[email protected]", $subject, $message, $headers);
Re: Email Attatchments PDF
It looks like you are missing a newline after the file data I believe.
Re: Email Attatchments PDF
Quote:
Originally Posted by visualAd
It looks like you are missing a newline after the file data I believe.
New Code:
Works In yahoo mail. Not in GMail.
PHP Code:
//Now Email the Invoice
$body = "Invoice Attatched!";
$to = $user->email;
$subject = 'Invoice -' . $orderNumber;
$bound_text = time() + 1;
$bound = "--".$bound_text."\r\n";
$bound_last = "--".$bound_text."--\r\n";
$headers = "From: [email protected]\r\n";
$headers .= "MIME-Version: 1.0\r\n"
. "Content-Type: multipart/mixed; boundary=\"$bound_text\"";
$message = "If you can see this MIME than your client doesn't accept MIME types!\r\n" .$bound;
$message .= "Content-Type: text/plain; charset=\"iso-8859-1\"\r\n"
. "Content-Transfer-Encoding: 7bit\r\n\r\n"
. $body
."\r\n"
.$bound;
$file = file_get_contents("invoices/$orderNumber.pdf");
$message .= "Content-Type: application/pdf; name=\"$orderNumber.pdf\"\r\n"
."Content-Transfer-Encoding: base64\r\n"
."Content-disposition: attachment; file=\"$orderNumber.pdf\"\r\n"
."\r\n"
.chunk_split(base64_encode($file))
."\r\n"
.$bound_last;
mail($to, $subject, $message, $headers);
mail("email2", $subject, $message, $headers);
Output in gmail
Quote:
Content-Type: multipart/mixed; boundary="1215093503"
If you can see this MIME than your client doesn't accept MIME types!
--1215093503
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
--1215093503
Content-Type: application/pdf; name="Silv1215093502.pdf"
Content-Transfer-Encoding: base64
Content-disposition: attachment; file="Silv1215093502.pdf"
JVBERi0xLjMKMyAwIG9iago8PC9UeXBlIC9QYWdlCi9QYXJlbnQgMSAwIFIKL1Jlc291cmNlcyAy
IDAgUgovQ29udGVudHMgNCAwIFI+PgplbmRvYmoKNCAwIG9iago8PC9GaWx0ZXIgL0ZsYXRlRGVj
b2RlIC9MZW5ndGggMzA4Pj4Kc3RyZWFtCniclZPLboMwEEX3fMUs281gDx4clknTVopaKQg2XSJw
U6IWVB6N+vd1HCGyaCAB8RA+Z5hr2QQbTyBrOHjfIGADEg72ubfXs/0iUdgDjufwisMt//L8dPsi
Blah Blah