PHP Code

PHP – Send email with attachments

It's fairly simple to send an email with PHP, using the mail() function. But how do you send an attachment with your email? This code I dug up on php.net will solve that problem.

For some reason I was getting an error when trying to paste the code into a blog post, so I'm just going to link to what I based it on:

The first code snippet is for sending an email with one attachment.

The second code snippet explains how to send multiple attachments with an email in PHP, by defining the 'boundary' for each attachment.

Share

Leave a Reply

Your email address will not be published. Required fields are marked *

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Anti-spam image