Send HTML emails using PHP with Ease

One of my clients recently asked for an email newsletter type solution where they remotely send an email address via XML to a PHP script that would then send an HTML email template off to that specific email address.  I spent some time looking around at different solutions only to find that apparently no one had a solution that would meet our needs - that meant writing the script from scratch!  

To send HTML emails using PHP (vs just sending a text email), what you will need to do is use PHP’s “mail” function and place the proper headers into the mail function’s “headers” field (seePHP’s mail function defenition for more info).  Here is an example:

mail($email, ‘Resource Nation’,
$body,
“From: <$from>\n” .
“MIME-Version: 1.0\n” .
“Content-type: text/html; charset=iso-8859-1″);

Just replace the $email and $from variables to your liking.  You can also read up in more detail onhow to construct emails using PHP but my above code is a quick and easy solution for those looking to just sent emails that contain HTML.  Happy HTML-emailing! 

Comments

Post new comment

The content of this field is kept private and will not be shown publicly.
CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
3 + 7 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.