Hi im just trying to send an email using PHPMAiler and smtp server of gmail! I thought that it could have been easier! What have I written wrong?
Did anyone also use PHPMAiler? Can anyone help me?
<?php
//per https://github.com/PHPMailer/PHPMailer/blob/master/examples/gmail.phps
date_default_timezone_set('Etc/UTC');
require ("PHPMailer/class.phpmailer.php");
$mail = new PHPMailer;
$mail->isSMTP();
$mail->SMTPDebug = 2;
$mail->Debugoutput = 'html';
$mail->Host = 'smtp.gmail.com';
$mail->Port = 587;
$mail->SMTPSecure = 'tls';
$mail->SMTPAuth = true;
$mail->Username = "[email protected]";
$mail->Password = "bip";
$mail->setFrom('[email protected]');
$mail->addAddress('[email protected]'); //the same as Username!
$mail->Subject = "PHPMailer GMail SMTP test";
$mail->Body = "HeLLO";
if(!$mail->send())
{
echo "Mailer Error: ". $mail->ErrorInfo;
}
else
{
echo "Message sent!";
}
?>