I am trying to use PHPMailer to send a gmail email. I followed this post
In order to do this, I set up a function shown below:
function sendEmail($
$mail = new PHPMailer();
// Set up SMTP
$mail->IsSMTP(); // Sets up a SMTP connection
$mail->SMTPDebug = 0; // This will print debugging info
$mail->SMTPAuth = true; // Connection with the SMTP does require authorization
$mail->SMTPSecure = "tls"; // Connect using a TLS connection
$mail->Host = "smtp.gmail.com";
$mail->Port = 587;
$mail->Encoding = '7bit'; // SMS uses 7-bit encoding
$mail->IsHTML(true); // Set email format to HTML
// Authentication
$mail->Username = "xxx@xxx.xxx.xx"; // Login
$mail->Password = "xxxxxx"; // Password
//$to=
$to = "zzz@zzz.zzz.zz";
$mail->Subject = "Outstanding Balance Notification "; // Subject (which isn't required)
$mail->Body = "Dear Sir / Madam";
$mail->FromName = "stackoverflow";
$mail->From = "noreply@xxx.xxx.xx";
$mail->AddAddress($row["Email1"]);
try this.. :)