Dec
18
2015

How to Send e-Mail using PHPMailer and Gmail SMTP

In this tutorial i will discuss How to Send e-Mail using PHPMailer and Gmail SMTP. With PHPMailer library one can send email from localhost as well as online server. Most of website owner send the mail using his own SMTP server but it will be better to send the mail using Gmail SMTP. The reason is if your site is hosted on shared hosting provider and you send bulk mail then there will be a big chance to blacklisted your website IP address. Because of some limitation of SMTP server. On the other hand Gmail SMTP server provide 500 recipients a day. For more information and limitation of  Gmail SMTP server check this information.

How to Send e-Mail using PHPMailer and Gmail SMTP

Download Code

How to send mail from Gmail SMTP.

1. Register your gmail account or setup your domain for Google applications.
2. Download a recent version of PHPMailer.
3. Check your hosting provider has opened the port 465 (TCP out). If not consult your hosting provider and ask him to open the port.
4. copy-paste the following script using your editor and save this file as “sendmail.php” and try it in your localhost server.

if you trouble sending e-mails check gmail username, password, and smtp port and try to change SMTPDebug value 0, 1, 2 it will give you error messages with details, and there is no need to do change in phpmailer class.

$mail->SMTPDebug = 0;.

I hope you understand very well How to Send e-Mail using PHPMailer and Gmail SMTP.

If you have any query regarding our tutorial How to Send e-Mail using PHPMailer and Gmail SMTP then you can comment.

 

About the Author: Sanjeev Kumar

Experienced PHP Web Developer and founder of www.codemarts.com. Expert in Codeigniter (MVC), WordPress, JSON, jQuery & HTML5.

Leave a comment