Michael
Michael

Reputation: 63

send php mail connecting through smtp.gmail.com

I'm trying to run this script to send an email

require_once('PHPMailer/PHPMailerAutoload.php');

$mail             = new PHPMailer();


$mail->IsSMTP();

$mail->Host = 'smtp.gmail.com';
$mail->SMTPAuth = true;
$mail->SMTPSecure = 'ssl';
$mail->Username = '[email protected]';
$mail->Password = 'mypass';
$mail->Port = '465';
$mail->SMTPDebug  = 1;

$mail->SetFrom('[email protected]', 'NAME SURNAME');

$mail->Subject    = 'FeedBack';

$mail->MsgHTML('hello');

$address = '[email protected]';
$mail->AddAddress($address);
$mail->Send();


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

?>

but it returns me these errors:

2015-03-09 21:29:37 CLIENT -> SERVER: EHLO www.mydomain.com

2015-03-09 21:29:37 CLIENT -> SERVER: AUTH LOGIN

2015-03-09 21:29:37 CLIENT -> SERVER: Y29pbGx0ZWFuY2FwaXRhbGRldmVsb3BknfBnbWFpbC5jb20=

2015-03-09 21:29:37 CLIENT -> SERVER: bmVgr2Vic2l0ZQ==

2015-03-09 21:29:37 SMTP ERROR: Password command failed: 534-5.7.14 Please log in via your web browser and then try again. 534-5.7.14 Learn more at 534 5.7.14 https://support.google.com/mail/bin/answer.py?answer=78754 n3sm29933619wja.36 - gsmtp

2015-03-09 21:29:37 CLIENT -> SERVER: QUIT

2015-03-09 21:29:37 SMTP connect() failed.

2015-03-09 21:29:37 CLIENT -> SERVER: EHLO www.mydomain.com

2015-03-09 21:29:37 CLIENT -> SERVER: AUTH LOGIN

2015-03-09 21:29:37 CLIENT -> SERVER: Y29pbGx0ZWFuY2FwaXRhbvRldcVsb3BlckBnbWFpbC5jb20=

2015-03-09 21:29:37 CLIENT -> SERVER: bmV3d2Vic2l0ZQ==

2015-03-09 21:29:37 SMTP ERROR: Password command failed: 534-5.7.14 Please log in via your web browser and 534-5.7.14 then try again. 534-5.7.14 Learn more at 534 5.7.14 https://support.google.com/mail/bin/answer.py?answer=78754 y14sm29932162wjr.39 - gsmtp

2015-03-09 21:29:37 CLIENT -> SERVER: QUIT 2015-03-09 21:29:37 SMTP connect() failed. Mailer Error: SMTP connect() failed.

I can't understand why. If I run this script locally on wamp server it works but If upload it on the online server (linux) It doesn't work.

Upvotes: 0

Views: 588

Answers (1)

Michael
Michael

Reputation: 63

Strange problem solved by removing $mail->IsSMTP();

Upvotes: 0

Related Questions