Use PHPMailer with gmail authentication


Download PHP Mailer from Here

<?php
require(“includes/class.phpmailer.php”);
$mailer = new PHPMailer();
$mailer->IsSMTP();

$mailer->Host = “smtp.gmail.com:587”;

$mailer->SMTPAuth = TRUE;
$mailer->Username = “{somename}@gmail.com”;  // Change this to your gmail adress
$mailer->Password = “{password}”;  // Change this to your gmail password
$mailer->From = “{someid}@gmail.com”;  // This HAVE TO be your gmail adress
$mailer->FromName = “Avinash”; // This is the from name in the email, you can put anything you like here
$mailer->Body = “This is the main body”;
$mailer->Subject = “This is mail from Avinash”;
$mailer->AddAddress(“{toaddress email id}”);  // This is where you put the email adress of the person you want to mail
if(!$mailer->Send())
{
echo “Message was not sent<br/ >”;
echo “Mailer Error: “ . $mailer->ErrorInfo;
}
else
{
echo “Message has been sent”;
}
?>

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s