Attaching PDF files in email

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
leewad
Forum Commoner
Posts: 91
Joined: Tue May 11, 2004 8:32 am

Attaching PDF files in email

Post 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
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post 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 ;)
leewad
Forum Commoner
Posts: 91
Joined: Tue May 11, 2004 8:32 am

Post 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.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post 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.
leewad
Forum Commoner
Posts: 91
Joined: Tue May 11, 2004 8:32 am

Post by leewad »

8O
Post Reply