php send e-mail with attachment

I’ve just looked at a couple of my emails, and I notice the the final attachment boundary ends with ‘–‘, while the opening boundary marker does not. In your code, you have:

--PHP-mixed-$random_hash--
Content-Type: text/plain; name=\"$filename\" 
Content-Transfer-Encoding: base64 
Content-Disposition: attachment 

$attachment
--PHP-mixed-$random_hash--

Perhaps it should be:

--PHP-mixed-$random_hash
Content-Type: text/plain; name=\"$filename\" 
Content-Transfer-Encoding: base64 
Content-Disposition: attachment 

$attachment
--PHP-mixed-$random_hash--

Have a look at the example here:

http://en.wikipedia.org/wiki/MIME#Multipart_messages

Leave a Comment