...

View Full Version : Multiple Email Attachments



NancyJ
02-20-2008, 01:47 PM
I'm trying to send 2 attachments with an email but only the first one comes through - I've googled til my fingers turned numb and all I find is questions, no solutions (just use PEAR/phpMailer is not a solution)

This is my code


$invoice_data = chunk_split(base64_encode(file_get_contents($invoice)));
$encoded_data = chunk_split(base64_encode(file_get_contents($checkin)));


$boundary = "------=_NextPart_000_13e7_6608_6142";

$headers = "From:Reservations<ops@everythingcannes.com\r\n";

$headers .= "Mime-Version: 1.0\r\n";
$headers .= 'Content-Type: multipart/mixed'.'; boundary="'. $boundary .'"' . "\r\n\r\n";
$headers2 .= "This is a multi-part message in MIME format.\r\n\r\n";
$headers2 .= "--$boundary\r\n";

$headers2 .= "Content-Type: text/html; charset=iso-8859-1; format=flowed\r\n";
$headers2 .= "Content-Transfer-Encoding: 7bit\r\n\r\n";

$headers2 .= "$content\r\n";
$headers2 .= "--$boundary\r\n";
$headers2 .= "Content-Type: application/pdf; name=". '"Check-in_Instructions.pdf"' . "\r\n";
$headers2 .= "Content-Transfer-Encoding: base64\r\n";
$headers2 .= "Content-Disposition: attachment; filename=". '"Check-in_Instructions.pdf"' . "\r\n\r\n";
$headers2 .= <<<EOT
$encoded_data
EOT;
$headers2 .= "\r\n\r\rn";
$headers2 .= "--$boundary\r\n";

$headers2 .= "Content-Type: application/pdf; name=". '"Invoice-'.$bid.'.pdf"' . "\r\n";
$headers2 .= "Content-Transfer-Encoding: base64\r\n";
$headers2 .= "Content-Disposition: attachment; filename=". '"Invoice-'.$bid.'.pdf"' . "\r\n\r\n";
$headers2 .= <<<EOT
$invoice_data
EOT;
$headers2 .= "\r\n\r\rn";
$headers2 .= "--$boundary\r\n";


$success = mail($email,"[ref:$bid] Your upcoming stay in $pname -- Info for Arrival & Checkin",$headers2,$headers);

NancyJ
02-20-2008, 02:10 PM
I found the issue - I copy and pasted another developers code (the guy that used to work on the site) and he obviously had fat fingers ;)


$headers2 .= "\r\n\r\rn";
should be


$headers2 .= "\r\n\r\n";



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum