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.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.
$mail = new PHPMailer();
$mail->CharSet = "utf-8";
$mail->SMTPAuth = true;
$mail->Username = "[email protected]";
$mail->Password = "your_gmail_password";
$mail->SMTPSecure = "ssl";
$mail->Host = "smtp.gmail.com";
$mail->Port = "465";
$mail->setFrom('[email protected]', 'your name');
$mail->AddAddress('[email protected]', 'receivers name');
$mail->Subject = 'using PHPMailer';
$mail->Body = 'Hi there ,
this mail was sent using PHPMailer...
echo "Message was Successfully Send :)";
echo "Mail Error - >".$mail->ErrorInfo;
$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.