Please note that I am using a Google Apps account and not a gmail account. I am trying to just send an email using my Google Apps account using php. I can send an email in a .net application using port 587 host smtp.googlemail.com and SSL. Username is my full email address.
require_once('PHPMailer_v5.1\class.phpmailer.php');
try {
$mail = new PHPMailer();
$mail->Mailer = 'smtp';
$mail->SMTPSecure = 'tls';
$mail->Host = $host;
$mail->Port = 587;
$mail->SMTPAuth = true;
$mail->Username = $from;
$mail->Password = $password;
$mail->AddAddress($to, $to_name);
$mail->From = $from;
$mail->FromName = $from_name;
$mail->Subject = $subject;
$mail->MsgHTML($body);
$mail->IsHTML(true);
$mail->Send();
} catch (phpmailerException $e) {
echo $e->errorMessage();
} catch (Exception $e) {
echo $e->getMessage();
}
Failed to get this to work, but I tried several different variations of this.
$mail->SMTPSecure = 'ssl';
$mail->Port = 465;
$mail->SMTPSecure = 'tls';
$mail->Port = 587;
I don't care, but I need to send an email using gmail. It can be with this library or another.
Chris source
share