PHP Send Email Via PHPMailer Example

How to send email using PHPMailer

PHP Send Email Via PHPMailerFor those of you who want to send email via PHPMailer instead of the mail() command, here is a simple script I wrote to facilitate sending email. Because there are so many different areas within a site that can send email messages automatically I have externalized the script and include it when needed.

The script includes logic to monitor for an error from PHPMailer and if found send the email using mail() and send an email to the administrator that PHPMailer failed.

This function accepts an optional file parameter. If the file parameter is passed it will be included in the email as an attachment.
Continue reading “PHP Send Email Via PHPMailer Example”