...

View Full Version : Mail Attachment



thoford75
09-08-2011, 10:37 AM
I'm looking to send a file on my server called 'Spreadsheet.xls' as an attachment in php mail.



include "../templates/email_body.php";


$email_headers = "From: tom@xyz.com\r\n";
$email_headers .= "BCC: joe@xyz.com\r\n";
$email_headers .= "Content-Type: text/html;\r\n charset=\"iso-8859-1\"\r\n";
mail("$customer_email","Sending Attachment",$email_message,$email_headers);


The file Spreadsheet.xls is in the same folder as this php file.

I've had a look around on google and it seems a lot harder to do than it should!? Most the articles are about uploading a document to be sent by email, but I already have the file to send...?

durangod
09-08-2011, 02:00 PM
i just googled php mail sending attachment and found several examples. you might try that, i have never done the attatchment deal myself but the examples are fairly clear.

thoford75
09-08-2011, 02:02 PM
Thanks, the examples found explain how to send an attached file that has been uploaded. I just want the code to send a file from my server. The only one I could find that looked close was one about sending a zip file, but there was a lot of extra coding for compression :(:thumbsup:

durangod
09-08-2011, 02:15 PM
well maybe we both can learn something here.

have you seen this

http://www.finalwebsites.com/forums/topic/php-e-mail-attachment-script

i was looking at this line, im not sure if thats all you need or not




$header .= "Content-Disposition: attachment;filename=\"".$filename."\"\r\n\r\n";

tangoforce
09-08-2011, 02:36 PM
Try using phpmailer. It makes life incredibly easy for sending emails, html emails, emails with attachments etc.

The only problem with it you might run into is on line 1471 where I had to change the php version from 6 to 5 (and then a few lines below) to stop php moaning about deprecated functions (magic quotes).



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum