Home » PHP24 October 2011

PHP: Easily send email with PHPMailer

PHPMailer is a PHP class for PHP that provides a package of functions to send email. It is an efficient way to send e-mail within PHP. The following are some features of PHPMailer:-

– Sending HTML email
– Sending email with attachments
– Sending email to multiple recepients via to, CC, BCC, etc
– Supports nearly all possiblities to send email: mail(), Sendmail, qmail & direct to SMTP server

Download PHPMailer

For PHP 4 | For PHP 5 and above

Sample Code Example

Note isMail() function in the code. This indicates that email is to be sent through mail() function of php.

Sending email using mail() function

Sending email using SMTP

Along with using SMTP to send email, other functions are also being used. Like, adding reply-to address and from address. Also, notice that multiple reply-to address and multiple to-address are being added. Attachment function is also being included in the below code. You can add multiple attachment.

Download PHPMailer

For PHP 4 | For PHP 5 and above

Hope it helps. Thanks.

From Mukesh Chapagain's Blog, post PHP: Easily send email with PHPMailer

php magento mukesh chapagain

Get New Post by Email

Find me on

Facebook Twitter Google+ LinkedIn RSS Feed
  • Ashwini Dinker

    Hi Mukesh

    I am trying to use your script but it gives the error-

    Mailer Error: The following From address failed: dinkeronline@gmail.com