Hi,
I'm trying to send an email from the php mail command. I've been able to what I've tried so far, but can't seem to get it to work with an attachment. I've looked around the web and the best code I've found led me to this:
$fileatt_name = 'JuneFlyer.pdf';
$fileatt_type = 'application/pdf';
$fileatt = 'JuneFlyer.pdf';
$file = fopen($fileatt,'rb');
$data = fread($file,filesize($fileatt));
$data = chunk_split(base64_encode($data));
$MAEmail = "
[email protected]";
mail("$email_address", "$subject", "$message",
"From: ".$MAEmail."\n".
"MIME-Version: 1.0\n".
"Content-type: text/html; charset=iso-8859-1".
"--{$mime_boundary}\n" .
"Content-Type: {$fileatt_type};\n" .
" name=\"{$fileatt_name}\"\n" .
"Content-Disposition: attachment;\n" .
" filename=\"{$fileatt_name}\"\n" .
"Content-Transfer-Encoding: base64\n\n" .$data. "\n\n" );
There are two problems when I do this. First, the contents of the email dissappear.
Second, there is an error on the attachment. "Adobe Reader could not open June_flyer.pdf because it is either not a supported file type or because the file has been damaged (for example it was sent as an email attachment and wasn't correctly decoded)"
Any ideas of how to deal with this?
Thanks,
JB