Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can not send mail from google smtp.. #561

Closed
dlhenke opened this issue Nov 16, 2015 · 37 comments
Closed

Can not send mail from google smtp.. #561

dlhenke opened this issue Nov 16, 2015 · 37 comments

Comments

@dlhenke
Copy link

dlhenke commented Nov 16, 2015

I'm using latest phpmailer..
can you please help me..

Connection: opening to smtp.gmail.com:587, timeout=300, options=array ()
Connection: opened
SMTP -> get_lines(): $data is ""
SMTP -> get_lines(): $str is "220 smtp.gmail.com ESMTP i201sm36810815ywe.10 - gsmtp"
SERVER -> CLIENT: 220 smtp.gmail.com ESMTP i201sm36810815ywe.10 - gsmtp
CLIENT -> SERVER: EHLO ws.arin.com.br
SMTP -> get_lines(): $data is ""
SMTP -> get_lines(): $str is "250-smtp.gmail.com at your service, [67.205.67.207]"
SMTP -> get_lines(): $data is "250-smtp.gmail.com at your service, [67.205.67.207]"
SMTP -> get_lines(): $str is "250-SIZE 35882577"
SMTP -> get_lines(): $data is "250-smtp.gmail.com at your service, [67.205.67.207]250-SIZE 35882577"
SMTP -> get_lines(): $str is "250-8BITMIME"
SMTP -> get_lines(): $data is "250-smtp.gmail.com at your service, [67.205.67.207]250-SIZE 35882577250-8BITMIME"
SMTP -> get_lines(): $str is "250-STARTTLS"
SMTP -> get_lines(): $data is "250-smtp.gmail.com at your service, [67.205.67.207]250-SIZE 35882577250-8BITMIME250-STARTTLS"
SMTP -> get_lines(): $str is "250-ENHANCEDSTATUSCODES"
SMTP -> get_lines(): $data is "250-smtp.gmail.com at your service, [67.205.67.207]250-SIZE 35882577250-8BITMIME250-STARTTLS250-ENHANCEDSTATUSCODES"
SMTP -> get_lines(): $str is "250-PIPELINING"
SMTP -> get_lines(): $data is "250-smtp.gmail.com at your service, [67.205.67.207]250-SIZE 35882577250-8BITMIME250-STARTTLS250-ENHANCEDSTATUSCODES250-PIPELINING"
SMTP -> get_lines(): $str is "250-CHUNKING"
SMTP -> get_lines(): $data is "250-smtp.gmail.com at your service, [67.205.67.207]250-SIZE 35882577250-8BITMIME250-STARTTLS250-ENHANCEDSTATUSCODES250-PIPELINING250-CHUNKING"
SMTP -> get_lines(): $str is "250 SMTPUTF8"
SERVER -> CLIENT: 250-smtp.gmail.com at your service, [67.205.67.207]250-SIZE 35882577250-8BITMIME250-STARTTLS250-ENHANCEDSTATUSCODES250-PIPELINING250-CHUNKING250 SMTPUTF8
CLIENT -> SERVER: STARTTLS
SMTP -> get_lines(): $data is ""
SMTP -> get_lines(): $str is "220 2.0.0 Ready to start TLS"
SERVER -> CLIENT: 220 2.0.0 Ready to start TLS
CLIENT -> SERVER: EHLO ws.arin.com.br
SMTP -> get_lines(): $data is ""
SMTP -> get_lines(): $str is "250-smtp.gmail.com at your service, [67.205.67.207]"
SMTP -> get_lines(): $data is "250-smtp.gmail.com at your service, [67.205.67.207]"
SMTP -> get_lines(): $str is "250-SIZE 35882577"
SMTP -> get_lines(): $data is "250-smtp.gmail.com at your service, [67.205.67.207]250-SIZE 35882577"
SMTP -> get_lines(): $str is "250-8BITMIME"
SMTP -> get_lines(): $data is "250-smtp.gmail.com at your service, [67.205.67.207]250-SIZE 35882577250-8BITMIME"
SMTP -> get_lines(): $str is "250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH"
SMTP -> get_lines(): $data is "250-smtp.gmail.com at your service, [67.205.67.207]250-SIZE 35882577250-8BITMIME250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH"
SMTP -> get_lines(): $str is "250-ENHANCEDSTATUSCODES"
SMTP -> get_lines(): $data is "250-smtp.gmail.com at your service, [67.205.67.207]250-SIZE 35882577250-8BITMIME250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH250-ENHANCEDSTATUSCODES"
SMTP -> get_lines(): $str is "250-PIPELINING"
SMTP -> get_lines(): $data is "250-smtp.gmail.com at your service, [67.205.67.207]250-SIZE 35882577250-8BITMIME250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH250-ENHANCEDSTATUSCODES250-PIPELINING"
SMTP -> get_lines(): $str is "250-CHUNKING"
SMTP -> get_lines(): $data is "250-smtp.gmail.com at your service, [67.205.67.207]250-SIZE 35882577250-8BITMIME250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH250-ENHANCEDSTATUSCODES250-PIPELINING250-CHUNKING"
SMTP -> get_lines(): $str is "250 SMTPUTF8"
SERVER -> CLIENT: 250-smtp.gmail.com at your service, [67.205.67.207]250-SIZE 35882577250-8BITMIME250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH250-ENHANCEDSTATUSCODES250-PIPELINING250-CHUNKING250 SMTPUTF8
Auth method requested: XOAUTH
Auth methods available on the server: LOGIN,PLAIN,XOAUTH2,PLAIN-CLIENTTOKEN,OAUTHBEARER,XOAUTH
SMTP Error: Could not authenticate.
CLIENT -> SERVER: QUIT
SMTP -> get_lines(): $data is ""
SMTP -> get_lines(): $str is "221 2.0.0 closing connection i201sm36810815ywe.10 - gsmtp"
SERVER -> CLIENT: 221 2.0.0 closing connection i201sm36810815ywe.10 - gsmtp
Connection: closed
SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

@Synchro
Copy link
Member

Synchro commented Nov 17, 2015

Like the error says:

Auth method requested: XOAUTH
Auth methods available on the server: LOGIN,PLAIN,XOAUTH2,PLAIN-CLIENTTOKEN,OAUTHBEARER,XOAUTH

You've requested an auth method that's not supported. If you're using OAuth2, you need to set $mail->AuthType = 'XOAUTH2'. Also make sure you read the docs.

@Synchro Synchro closed this as completed Nov 17, 2015
@dlhenke
Copy link
Author

dlhenke commented Nov 17, 2015

hey.. that was a second try..
XOAUTH2, XOAUTH ..

@dlhenke
Copy link
Author

dlhenke commented Nov 17, 2015

PIPELINING250-CHUNKING250 SMTPUTF8
Auth method requested: XOAUTH2
Auth methods available on the server: LOGIN,PLAIN,XOAUTH2,PLAIN-CLIENTTOKEN,OAUTHBEARER,XOAUTH
CLIENT -> SERVER: AUTH XOAUTH2 dXNlcj1hZnBlc3AuYXJpbkBnbWFpbC5jb20BYXV0aD1CZWFyZXIgeWEyOS5Md0twb2V3c0NIN21QaTViLTFLcE8tYUZaNGxWenhWWGRvV3RjN3kzZVR5T09oMnNiNGNMcS1mYUZUaEZPak1KZC1tazB3AQE=
SMTP -> get_lines(): $data is ""
SMTP -> get_lines(): $str is "334 eyJzdGF0dXMiOiI0MDAiLCJzY2hlbWVzIjoiQmVhcmVyIiwic2NvcGUiOiJodHRwczovL21haWwuZ29vZ2xlLmNvbS8ifQ=="
SERVER -> CLIENT: 334 eyJzdGF0dXMiOiI0MDAiLCJzY2hlbWVzIjoiQmVhcmVyIiwic2NvcGUiOiJodHRwczovL21haWwuZ29vZ2xlLmNvbS8ifQ==
SMTP ERROR: AUTH command failed: 334 eyJzdGF0dXMiOiI0MDAiLCJzY2hlbWVzIjoiQmVhcmVyIiwic2NvcGUiOiJodHRwczovL21haWwuZ29vZ2xlLmNvbS8ifQ==
SMTP Error: Could not authenticate.
CLIENT -> SERVER: QUIT
SMTP -> get_lines(): $data is ""
SMTP -> get_lines(): $str is "535-5.7.8 Username and Password not accepted. Learn more at"
SMTP -> get_lines(): $data is "535-5.7.8 Username and Password not accepted. Learn more at"
SMTP -> get_lines(): $str is "535 5.7.8 https://support.google.com/mail/answer/14257 x139sm2326702vkd.7 - gsmtp"
SERVER -> CLIENT: 535-5.7.8 Username and Password not accepted. Learn more at535 5.7.8 https://support.google.com/mail/answer/14257 x139sm2326702vkd.7 - gsmtp
SMTP ERROR: QUIT command failed: 535-5.7.8 Username and Password not accepted. Learn more at535 5.7.8 https://support.google.com/mail/answer/14257 x139sm2326702vkd.7 - gsmtp
Connection: closed
SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

@usamamashkoor
Copy link

did you find any solution...?

@Synchro
Copy link
Member

Synchro commented Aug 20, 2017

You must have done something wrong in configuring your Gmail oauth credentials. It works fine for me and others, and the delivery of credentials itself is very simple. Setting them up is very complex and error-prone, but that's Gmail, not PHPMailer. Work through the oauth docs in the wiki.

@josebulatao
Copy link

SMTP -> FROM SERVER:220 smtp.gmail.com ESMTP c6sm21581911pfm.165 - gsmtp
SMTP -> FROM SERVER: 250-smtp.gmail.com at your service, [205.144.171.59] 250-SIZE 35882577 250-8BITMIME 250-STARTTLS 250-ENHANCEDSTATUSCODES 250-PIPELINING 250-CHUNKING 250 SMTPUTF8
SMTP -> ERROR: AUTH not accepted from server: 530 5.7.0 Must issue a STARTTLS command first. c6sm21581911pfm.165 - gsmtp
SMTP -> FROM SERVER:250 2.1.5 Flushed c6sm21581911pfm.165 - gsmtp
SMTP Error: Could not authenticate. Mailer Error: SMTP Error: Could not authenticate.

i am having this error.. please help me

@Synchro
Copy link
Member

Synchro commented Feb 27, 2018

Make sure you're using the latest version, and base your code on the gmail example provided.

@josebulatao
Copy link

i am using the latest version of the PHPmailer.. can you please provide me an php example for sending email ?

@Synchro
Copy link
Member

Synchro commented Feb 27, 2018

Is it really so hard to find the ones that are right here?

@josebulatao
Copy link

josebulatao commented Feb 28, 2018 via email

@ooxi
Copy link

ooxi commented Feb 28, 2018

Please paste the output of running composer require phpmailer/phpmailer. We might have to move this discussion to a more suitable place like stackoverflow since this is clearly not a PHPMailer issue.

@josebulatao
Copy link

josebulatao commented Feb 28, 2018 via email

@ooxi
Copy link

ooxi commented Feb 28, 2018

[image: Inline image 1]

Most likely you are trying to send an image to GitHub via mail. Please log into GitHub and paste your console output here.

@josebulatao
Copy link

sa

@josebulatao
Copy link

i'll just start over from the scratch.. please help me set up phpmailer

@ooxi
Copy link

ooxi commented Feb 28, 2018

Please make sure you read the instructions carefully. The command is called composer not compose. Do you have composer installed on your system? If not you can follow the Composer installation guide for Windows.

@josebulatao
Copy link

So that's what im missing... Thanks alot ! :) Downloading PHPmailer now...

@ooxi
Copy link

ooxi commented Feb 28, 2018

So that's what im missing... Thanks alot ! :) Downloading PHPmailer now...

Sure thing :-)

@josebulatao
Copy link

sdadasdasd
getting this error from smtp.. i used smtp.gmail.com

@ooxi
Copy link

ooxi commented Feb 28, 2018

Are you using the GMail example?

Also please paste verbatim instead of images. Think of the visually impaired :-)

@josebulatao
Copy link

yes... everytime i use gmail the smtp error is always occuring

@ooxi
Copy link

ooxi commented Feb 28, 2018

Please remove the lines after 2018-02-28 02:07:03 CLIENT -> SERVER: AUTH LOGIN, those are your username and password!

@josebulatao
Copy link

oh im sorry hahaha

@josebulatao
Copy link

2018-02-28 02:12:11 SERVER -> CLIENT: 220 smtp.gmail.com ESMTP s127sm603999pfb.178 - gsmtp
2018-02-28 02:12:11 CLIENT -> SERVER: EHLO maybanksurvey-001-site1.atempurl.com
2018-02-28 02:12:11 SERVER -> CLIENT: 250-smtp.gmail.com at your service, [205.144.171.59]250-SIZE 35882577250-8BITMIME250-STARTTLS250-ENHANCEDSTATUSCODES250-PIPELINING250-CHUNKING250 SMTPUTF8
2018-02-28 02:12:11 CLIENT -> SERVER: STARTTLS
2018-02-28 02:12:11 SERVER -> CLIENT: 220 2.0.0 Ready to start TLS
SMTP Error: Could not connect to SMTP host.
2018-02-28 02:12:13 CLIENT -> SERVER: QUIT
2018-02-28 02:12:13
2018-02-28 02:12:13
SMTP Error: Could not connect to SMTP host.
Message could not be sent. Mailer Error: SMTP Error: Could not connect to SMTP host.

this is the error from smtp.gmail.com

@ooxi
Copy link

ooxi commented Feb 28, 2018

It looks like smtp.sendgrid.net is accepting plain login, whereas GMail requires OAuth. Also it does not really work, as you are using smtp.sendgrid.net to send an E-Mail from [email protected]. Most recipients will drop the mail since your mail server is not allowed to send E-Mails in the name of gmail.com

@ooxi
Copy link

ooxi commented Feb 28, 2018

Sorry I was pointing you at the wrong example, please try gmail_xoauth. Also since it's quitting immediately after STARTTLS your CA certificates might be out of date.

@ooxi
Copy link

ooxi commented Feb 28, 2018

If the XOAuth example also does not work, try adding this from the troubleshooing guide:

$mail->SMTPOptions = array(
    'ssl' => array(
        'verify_peer' => false,
        'verify_peer_name' => false,
        'allow_self_signed' => true
    )
);

Please note that this is not a real solution since it allows active eavesdropping. It's just a quick test to check whether your CA certificates need to get updated.

@josebulatao
Copy link

use League\OAuth2\Client\Provider\Google; this file doesn't exist in my directory

@ooxi
Copy link

ooxi commented Feb 28, 2018

We're getting closer :-)

Please execute composer require league/oauth2-google to download a Google OAuth implementation from The League and then retry.

@josebulatao
Copy link

yes close hahaha

@josebulatao
Copy link

$mail->setOAuth(
new OAuth(
[
'provider' => $provider,
'clientId' => $clientId,
'clientSecret' => $clientSecret,
'refreshToken' => $refreshToken,
'[email protected]' => $email,
]
)
);

what should i input here ? :(

@ooxi
Copy link

ooxi commented Feb 28, 2018

You should not have to change anything between lines 58 to 77.

You have to configure your account credentials in lines 48 to 56.

@ooxi
Copy link

ooxi commented Feb 28, 2018

If you don't know where to get those credentials, please make sure to follow the GMail OAuth Guide :-)

@josebulatao
Copy link

i can't get the Gmail OAuth.. i think i'll stick with sendgrid for now.. Thankyou ! @ooxi

@Synchro
Copy link
Member

Synchro commented Feb 28, 2018

Thanks for picking this up @ooxi. I suspect the main problem here is that @josebulatao has outdated CA certificates, which prevents gmail's certificate from being verified at the client end - gmail changed their cert not so long ago and this has been a very common result. Disabling verification should be a workaround for that, but the right fix is to download a new CA cert bundle and tell PHP to use that - this is described in the troubleshooting guide. You would need to do this even if using OAuth, since OAuth authentication happens after a TLS session has been established.

@josebulatao
Copy link

sir @Synchro do you have a sample for making a html be downloaded as pdf file.. i am creating a online request form and want to printout the filled out form.

@Synchro
Copy link
Member

Synchro commented Feb 28, 2018

That's not really an email question - look at projects like tcpdf. Generally you'll get much better results if you generate PDFs directly using submitted form values rather than converting from HTML.

@PHPMailer PHPMailer deleted a comment from nomankh000123 May 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants