The PHPMailer library is quite complete and very commonly used among PHP developers. So the tip is how to configure it to send emails using GMail's SMTP.
require_once 'PHPMailer/PHPMailerAutoload.php';
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPDebug = 0;
$mail->SMTPAuth = true;
$mail->SMTPSecure = 'tls';
$mail->Host = 'smtp.gmail.com';
$mail->Port = 587;
$mail->Username = "envio@email.com.br";
$mail->Password = "********";
$mail->SetFrom("envio@email.com.br", "CronJob");
$mail->Subject = "Uma excecao ocorreu.";
$mail->Body = $text;
$mail->AddAddress($to);
if(!$mail->Send()) {
echo 'Mail error: '.$mail->ErrorInfo;
return false;
} else {
echo 'Message sent!';
return true;
}
Comments 0
No comments yet.