Forums

Sometimes Failed to send email by Gmail

I want to send web app(Flask) users an email to confirm their account. Here is my app config for mails:

app.config.update(DEBUG=True, MAIL_SERVER='smtp.gmail.com',MAIL_PORT=587,MAIL_USE_TLS=True,MAIL_USERNAME='david991010@gmail.com', MAIL_PASSWORD='my gmail password')

Sometimes the email successfully received,and the server.log print:enter image description here But when i tried to sent an email again,the server.log output stopped here.enter image description here I have waited for more than half an hour.Could it be faster or is it anything went wrong?Thanks.

Half an hour certainly should be enough time. Have you checked your Gmail security settings? While I'd expect that they would either always block email from your app, or never block it, rather than sometimes blocking it, their security systems can be a bit opaque. If you check out our help page on sending email there's a link to the appropriate part of their site.

I sent another test mail at [15/Feb/2016:11:49:38 +0000] but until now I didn't receive it.Gmail did not sent me a security warn for this as well.There is output in server log about it(DEBUG ON).Also error log did not report anything.@giles,I have set an App passwords for my web app.

P.S. at 2016-02-15 05:50:44 +0000 I tested a email and it received successfully.

Finally I got this Timeout error:

2016-02-15 13:33:58 send: 'ehlo [127.0.0.1]\r\n'

2016-02-15 13:33:58 reply: b'451 4.4.2 Timeout - closing connection. f83sm10916510qkb.25 - gsmtp\r\n'

2016-02-15 13:33:58 reply: retcode (451); Msg: b'4.4.2 Timeout - closing connection. f83sm10916510qkb.25 - gsmtp'

2016-02-15 13:34:11 pass error

Now I have sent another one,waiting again...

Now it stopped at : 2016-02-15 13:38:01 send: 'ehlo [127.0.0.1]\r\n'

2016-02-15 13:38:01 reply: b'250-smtp.gmail.com at your service, [50.17.220.95]\r\n'

2016-02-15 13:38:01 reply: b'250-SIZE 35882577\r\n'

2016-02-15 13:38:01 reply: b'250-8BITMIME\r\n'

2016-02-15 13:38:01 reply: b'250-STARTTLS\r\n'

2016-02-15 13:38:01 reply: b'250-ENHANCEDSTATUSCODES\r\n'

2016-02-15 13:38:01 reply: b'250-PIPELINING\r\n'

2016-02-15 13:38:01 reply: b'250-CHUNKING\r\n'

2016-02-15 13:38:01 reply: b'250 SMTPUTF8\r\n'

2016-02-15 13:38:01 reply: retcode (250); Msg: b'smtp.gmail.com at your service, [50.17.220.95]\nSIZE 35882577\n8BITMIME\nSTARTTLS\nENHANCEDSTATUSCODES\nPIPELINING\nCHUNKING\nSMTPUTF8'

2016-02-15 13:38:01 send: 'STARTTLS\r\n'

2016-02-15 13:38:01 reply: b'220 2.0.0 Ready to start TLS\r\n'

2016-02-15 13:38:01 reply: retcode (220); Msg: b'2.0.0 Ready to start TLS'

Now it is 2016-02-15 14:44 +0000 I do not receive it ...try agian...

Did you check out the link at the bottom of that help page I linked in my last post? Google don't necessarily alert you (via email or anything like that) when they think an email was sent by someone trying to hack your account -- you have to go to a specific page to see anything useful...

@giles After google for hours,i found Mailgun is a good choice.it will response to http post request but not smtp.Also, its api website is in whitesite of pythonanywhere ;D.In addition, it is faster than the SMTP of gmail,in less than 2mins,my email was received.

:)

I can confirm that Mailgun is great. I found yesterday sendgrid.com as nice alternative.

Thanks for letting us know! I'll add that to our help page for sending email.

[edit] Updated.