after trying to let my PHPMailer run with gmail for some days I have to find some help here. I read nearly everything I could find here or in Google but none of the ideas helped until now. I am using * Windows 7 Home Basic * Wampserver 2.2 with PHP vers. PHP Version 5.4.3 all necessary extensions are set up like e. g. php_opensll * PHPMailer 5.2.9
This is the script I am using:
<?php
//require 'PHPMailerAutoload.php'; // <<== I have tried this also - no sucess
require 'class-phpmailer.php';
require "class-smtp.php"; //"PHPMailerAutoload.php";
// $mail->PluginDir //WB, 30 Nov 2014:omited if all files from phpmailer are in the same folder
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Host = "smtp.gmail.com";
$mail->Mailer = 'smtp';
$mail->SMTPAuth = true;
// I have tried both - TLS and SSL - with the required ports ==>> both are not working
$mail->Port = 465;
$mail->SMTPSecure = 'ssl';
// or try these settings (worked on XAMPP and WAMP):
//$mail->Port = 587;
//$mail->SMTPSecure = 'tls';
$mail->Username = "wie****@gmail.com"; //my password ==>> works if I make a login oline to my account
$mail->Password = "*************"; //my password ==>> works if I make a login oline to my account
$mail->SMTPDebug = 2; // <<== enables SMTP debug information (for testing)
$mail->IsHTML(true); // if you are going to send HTML formatted emails
$mail->SingleTo = true; // if you want to send a same email to multiple users. multiple emails will be sent one-by-one.
$mail->From = "wie****@gmail.com"; //my gmail mail account
$mail->FromName = "My Name";
$mail->addAddress("art******@yahoo.com","art******"); //my yahoo mail account
//$mail->addAddress("[email protected]","User 2");
//$mail->addCC("[email protected]","User 3");
//$mail->addBCC("[email protected]","User 4");
$mail->Subject = "Testing PHPMailer with localhost";
$mail->Body = "Hi,<br /><br />This system is working perfectly.";
if(!$mail->Send())
echo "Message was not sent <br />PHPMailer Error: " . $mail->ErrorInfo;
else
echo "Message has been sent";
?>
I am trying already any variation I could found in the net but nothing works.
I have tried it with - 'PHPMailerAutoload.php' and 'class.phpmailer.php' as required class - “$mail->SMTPSecure = 'ssl';” and “$mail->Port = 465;” as well as with - “$mail->SMTPSecure = 'tls';” and “$mail->Port = 587;”
Here are the debugging log-files:
Debug-Log when using TLS with port 587
SMTP -> FROM SERVER:220 mx.google.com ESMTP cq6sm24503844pad.30 - gsmtp SMTP -> FROM SERVER: 250-mx.google.com at your service, [121.54.112.183] 250-SIZE 35882577 250-8BITMIME 250-STARTTLS 250-ENHANCEDSTATUSCODES 250-PIPELINING 250-CHUNKING 250 SMTPUTF8 SMTP -> FROM SERVER:220 2.0.0 Ready to start TLS SMTP -> FROM SERVER: 250-mx.google.com at your service, [121.54.112.183] 250-SIZE 35882577 250-8BITMIME 250-AUTH LOGIN PLAIN XOAUTH XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER 250-ENHANCEDSTATUSCODES 250-PIPELINING 250-CHUNKING 250 SMTPUTF8 SMTP -> ERROR: Password not accepted from server: 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 cq6sm24503844pad.30 - gsmtp SMTP -> FROM SERVER:250 2.1.5 Flushed cq6sm24503844pad.30 - gsmtp SMTP -> FROM SERVER:530-5.5.1 Authentication Required. Learn more at 530 5.5.1 http://support.google.com/mail/bin/answer.py?answer=14257 cq6sm24503844pad.30 - gsmtp SMTP -> ERROR: MAIL not accepted from server: 530-5.5.1 Authentication Required. Learn more at 530 5.5.1 http://support.google.com/mail/bin/answer.py?answer=14257 cq6sm24503844pad.30 - gsmtp The following From address failed: [email protected] : MAIL not accepted from server,530,5.5.1 Authentication Required. Learn more at 530 5.5.1 http://support.google.com/mail/bin/answer.py?answer=14257 cq6sm24503844pad.30 - gsmtp
SMTP server error: 5.5.1 Authentication Required. Learn more at 530 5.5.1 http://support.google.com/mail/bin/answer.py?answer=14257 cq6sm24503844pad.30 - gsmtp Message was not sent PHPMailer Error: The following From address failed: [email protected] : MAIL not accepted from server,530,5.5.1 Authentication Required. Learn more at 530 5.5.1 http://support.google.com/mail/bin/answer.py?answer=14257 cq6sm24503844pad.30 - gsmtp
SMTP server error: 5.5.1 Authentication Required. Learn more at 530 5.5.1 http://support.google.com/mail/bin/answer.py?answer=14257 cq6sm24503844pad.30 - gsmtp
SMTP server error: 5.5.1 Authentication Required. Learn more at 530 5.5.1 http://support.google.com/mail/bin/answer.py?answer=14257 cq6sm24503844pad.30 - gsmtp
Debug-Log when using SSL with port 465
SMTP -> FROM SERVER:220 mx.google.com ESMTP kj9sm24304154pbc.37 - gsmtp SMTP -> FROM SERVER: 250-mx.google.com at your service, [121.54.112.183] 250-SIZE 35882577 250-8BITMIME 250-AUTH LOGIN PLAIN XOAUTH XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER 250-ENHANCEDSTATUSCODES 250-PIPELINING 250-CHUNKING 250 SMTPUTF8 SMTP -> ERROR: Password not accepted from server: 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 kj9sm24304154pbc.37 - gsmtp SMTP -> FROM SERVER:250 2.1.5 Flushed kj9sm24304154pbc.37 - gsmtp SMTP -> FROM SERVER:530-5.5.1 Authentication Required. Learn more at 530 5.5.1 http://support.google.com/mail/bin/answer.py?answer=14257 kj9sm24304154pbc.37 - gsmtp SMTP -> ERROR: MAIL not accepted from server: 530-5.5.1 Authentication Required. Learn more at 530 5.5.1 http://support.google.com/mail/bin/answer.py?answer=14257 kj9sm24304154pbc.37 - gsmtp The following From address failed: [email protected] : MAIL not accepted from server,530,5.5.1 Authentication Required. Learn more at 530 5.5.1 http://support.google.com/mail/bin/answer.py?answer=14257 kj9sm24304154pbc.37 - gsmtp
SMTP server error: 5.5.1 Authentication Required. Learn more at 530 5.5.1 http://support.google.com/mail/bin/answer.py?answer=14257 kj9sm24304154pbc.37 - gsmtp Message was not sent PHPMailer Error: The following From address failed: [email protected] : MAIL not accepted from server,530,5.5.1 Authentication Required. Learn more at 530 5.5.1 http://support.google.com/mail/bin/answer.py?answer=14257 kj9sm24304154pbc.37 - gsmtp
SMTP server error: 5.5.1 Authentication Required. Learn more at 530 5.5.1 http://support.google.com/mail/bin/answer.py?answer=14257 kj9sm24304154pbc.37 - gsmtp
SMTP server error: 5.5.1 Authentication Required. Learn more at 530 5.5.1 http://support.google.com/mail/bin/answer.py?answer=14257 kj9sm24304154pbc.37 - gsmtp
I checked the links gmail is offering with the debugging. But nothing works. When I log into my account on the web with the same information for user and password it works.
I also followed the advices I found in the net to allow less secure apps. Also I allowed the access to my account with Google using the link https://accounts.google.com/DisplayUnlockCaptcha
Then I checked the ports with a port scanner both ports are mentioned as closed. But I guess they will be opened when requested by an application. A check with telnet smtp.gmail.com has been successful.
I tried the script also without running any antivirus and firewall – no result.
Slowly slowly I run a little bit mad with this issue. May be someone can help me here.
Andreas
Arthur, it is tuff to answer with out knowing the correct details. I mean, if you have two factor authentication enabled, you'll need to setup an application specific password to use in place of your email account's password.
You can generate an application specific password by following these instructions: https://support.google.com/accounts/answer/185833
Then set $mail->Password to your application specific password.
Random Work Around: some times, we have to enable the two step verification for some accounts then it will work (I did not know the correct reasons behind it, but this works for some accounts)
But from outside, Here are some hints to troubleshoot this: 1) check again [You said U checked it] SSL correctly configured on your PHP (module that handle it isn't installed by default on PHP. You have to check your configuration in phph.ini). 2) check if your firewall let outgoing calls to the required port (here 465 or 587). Use telnet to do so. If the port isn't opened, you'll then require some support from sysdmin to setup the config. 3) Open this https://support.google.com/mail/answer/14257?hl=en and select follow the instructions,google servers blocks any attempts from unknown servers so once you click on captcha check every thing will be fine
I hope you'll sort this out quickly!