Page 1 of 1

Attaching PDF files in email

Posted: Thu Mar 15, 2007 12:32 pm
by leewad
Hi

I`m trying to send out an email with 3 different pdf files but can only get it work with 1 file

here is my exisiting code:

Code: Select all

<?
$namefile=  "PDF_files/file1.pdf";
$namefile2= "PDF_files/file2.pdf";
$namefile3= "PDF_files/file3.pdf";

$to = 'myemail';
$subject = 'Test email with attachments';
$message="test";
$headers ="Content-Type: application/pdf; name=\"".$namefile."\"";
$mail_sent = @mail( $to, $subject, $message, $headers );

echo $mail_sent ? "Mail sent" : "Mail failed";
?>
can anyone please help me where to put the code to add the other 2

Thanks

Posted: Thu Mar 15, 2007 12:51 pm
by Chris Corbyn
http://www.swiftmailer.org/

Not sure what you're trying to do with mail()... I doin't see where you actually build the message. Swift will do it for you anyway ;)

Posted: Thu Mar 15, 2007 1:12 pm
by leewad
The code above sends the first file but i need to know how to send all 3 files (as an attachment) in the email, the message is irelevent, I will be adding that later.

Posted: Thu Mar 15, 2007 1:17 pm
by Chris Corbyn
Did you read my first post and go to that link. mail() isn't built to do this unless you understand MIME inside-out and I'm not particularly giddy enough to sit down and give a MIME tutorial unfortunately.

If you'd like the read the RFCs try 2822, 2045-8.

EDIT | FYI, that code definitely DOES NOT send an attachment. It sends the filename in the headers, but no attachment.

Posted: Thu Mar 15, 2007 1:21 pm
by leewad
8O