Code: Select all
tags when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
I've got a problem trying to email two attachments. My message emails fine but only the first attachment is sent. I've tried switching the order of the attachments but still only get the first one. Anyone help me with this?Code: Select all
// Sending Email message to applicant
$to = "$memEmail";
$from = "me <info@mydomain.ca>";
$subject = "Applciation Approved";
$message = "Thank you for your submission. The course is $course.";
$fileatt = "Cert.pdf";
$fileatt2 = "Letter.pdf";
// Read the file to be attached ('rb' = read binary)
$file = fopen($fileatt,'rb');
$data = fread($file,filesize($fileatt));
fclose($file);
// Read the file to be attached ('rb' = read binary)
$file = fopen($fileatt2,'rb');
$data2 = fread($file,filesize($fileatt2));
fclose($file);
// Generate a boundary string
$data = chunk_split(base64_encode($data));
$data2 = chunk_split(base64_encode($data2));
$num = md5( time() );
// Add the overall headers with type shown for a file attachment
$hdr = "From:$from\r\n";
$hdr .= "MIME-Version: 1.0\r\n";
$hdr .= "Content-Type: multipart/mixed; ";
$hdr .= "boundary=$num\r\n";
$hdr .= "--$num\r\n";
// this adds the text section
$hdr .= "Content-Type: text/plain\r\n";
$hdr .= "Content-Transfer-Encoding: 8bit\r\n\n";
$hdr .= "$message\r\n";
$hdr .= "--$num\n";
// this adds the first attachment
$hdr .= "Content-Type: $att_type; ";
$hdr .= "name="$fileatt2"\r\n";
$hdr .= "Content-Transfer-Encoding: base64\r\n";
$hdr .= "Content-Disposition: attachment; ";
$hdr .= "filename="$fileatt2"\r\n\n";
$hdr .= "$data2\r\n";
$hdr .= "--$num--";
// add the next attachment
$hdr .= "Content-Type: $att_type; ";
$hdr .= "name="$fileatt"\r\n";
$hdr .= "Content-Transfer-Encoding: base64\r\n";
$hdr .= "Content-Disposition: attachment; ";
$hdr .= "filename="$fileatt"\r\n\n";
$hdr .= "$data\r\n";
$hdr .= "--$num--";
mail($to, $subject, $message, $hdr); // send the e-mailfeyd | Please use
Code: Select all
tags when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]