0

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!";
}

?>

2 Answers 2

0

Many good threads on this in regular stack exchange

https://stackoverflow.com/q/18101769/3825826

0

Yeah actually the code is good! My gmail account just wasnt allowing weird apps like this t access it at the time!

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .