PHPology is a collective of highly skilled, award winning, web gurus.
Contact Raj on 07985 467 213 or email [email protected]

Sending emails via Gmail SMTP with PHPmailer

Had to use PHPMailer to send emails via Gmail SMTP and the PHPMailer version I was using was old skool but with a download of the latest code everything was good :-)

Below is a quick snippet of the code and the SMTPSecure property was key: 


$mail = new PHPMailer();
$mail->IsSMTP();                // send via SMTP
$mail->SMTPDebug  = 0;   //use 2 for full on report
$mail->Host     = ""; // SMTP servers
$mail->SMTPSecure = "ssl";          // sets the prefix to the server
$mail->SMTPAuth = true;     // turn on SMTP authentication
$mail->Username = "raj.gorsia[at]"; // SMTP username
$mail->Password = "enter_here"; // SMTP password
$mail->Port = 456; // SMTP port

        $mail->From     = "raj.gorsia[at]";
$mail->FromName = "PHPology";
$mail->IsHTML(true);     // send as HTML

$mail->Subject  =  $subject;
$mail->Body     =  $message;

$mail->SetLanguage("en", './system/classes/phpmailer/language/');

if($mail->Send()) {
echo "sent";
} else {
echo "Mailer Error: " . $mail->ErrorInfo;


Download PHPmailer here