How to Use PHP Mailer - Easy Way

How to Use PHP Mailer – Easy Way

Here I’m going to work on PHP Mailer to send emails. PHP Mailer is one of the most popular open source PHP library to send emails with. Before start using PHP Mailer, we have to download PHPMailer and extract these files inside our project directory to include these files in our project to send emails.

Download PHPMailer from GitHub

You can also get the PHPMailer sample code from the same github page or else you can copy the below code and start modify it.

You can start from above sample code, be sure to check the included file path. If there is any mistake you will get an error.

Then edit the code as per your requirement.

From line number 8 to 14 are SMTP settings, Here I’m using amazon SES service. If you want you can use Gmail’s SMTP settings.

From line number 16 to 21 are send from and send to email address, I’ve removed unnecessary lines like cc & bcc lines

And I’m not sending any attachments in the email so I’m commenting lines 23 & 24.

You can change the subject & message, load this file in browser.

If PHPMailer successfully sent an email, you can see a success message. Then you can check email to see this message.

For more information, you can check this below video.

If you have any problem, let me know through comment form below.

Vivek Vengala

Vivek Vengala is a Online Entrepreneur, Web Developer from Hyderabad India.

Click Here to Leave a Comment Below 0 comments

Leave a Reply: