Forums

Mailing with gmail from web2py

[admin update 2013-10-28: see the wiki section on email/smtp]

Following the standard web2py mail setup here:

https://web2py.com/books/default/chapter/29/08#Setting-up-email

made Google send me an automated message say that there was some "suspicious behavior" on my e-mail account and that I could follow this help page to enable the "client" (web2py@pythonanywhere@aws I assume)

http://www.google.com/accounts/DisplayUnlockCaptcha

I tried lynx from a bash shell, but to no avail. Is there a way to do this from PythonAnywhere or is there some workaround? I suppose I could use another smtp server if necessary, but just wanted to give a shout in case someone can help with this.

Hmm, that's awkward. I did get a warning like that when I started using Gmail as an SMTP server from PythonAnywhere, but it didn't ask me to use a browser from PythonAnywhere to unlock it.

So, I'm stumped. Anyone else have any ideas?

Do you have two-factor authentication turned on?

No, not that I know of. I would have posted the mail here, but it's in Danish, so I guess it's not of much help to you.

Today, when logging in via Chrome to my GMail account, there was a red bar at the top, that said that "there had been a suspicious login attempt from an unknown IP-address" (quickly paraphrased from Danish) I went through the same procedure as I tried yesterday, but this time there was a list of two AWS IP addresses that I had to acknowledge. When I did so, it said I should use the "client" within 10 minutes. I tried from my web2py app, and this time it worked Problem solved!

I have both a GMail address and a hosted Google Apps, and a quick guess could be that the link in the mail led me to the Google Apps domain login, but it was the GMail adress I used.

Final question: I have now acknowledged two AWS IP addresses for PythonAnywhere. Will these addresses ever change, and could I therefore see the problem again?

@jensk: Welcome to the PA community. I hope your time here ROCKS!!

As to the IP address changing question, I'd expect yes, but wait for an official response on that.

Thanks. Yes, so far PA rocks, fulfills my needs and even had features I didn't dream of myself - awesome! If my future experiments go as smooth as so far, I'll be signing up for sure.

Resistance is futile...☺

You're right! Check out my new signature star! :-D

Hi Jensk, I haven't encountered your exact problem before. I would suspect, like @rcs1000, that it was something to do with two factor authentication (which means you need to use a special one off, throw away password for each application you want to give access to) but this sounds like a different problem. Maybe the settings on your Google Apps domain are quite restrictive? I know you can tune those to be very security conscious and I think the defaults are.

@jensk: Nice!!

@hansel I do not have two factor authentication turned on, but I got it working by logging into my GMail via a webbrowser on my regular machine and authorizing the "suspicious" login attempts. Somehow it only worked the next day, or it was a problem with multiple Google logins. Regardless, it is solved now.

I have the same problem, but I can't find a way to solve this.

I'm pretty sure I told gMail that I recognized the "suspicious activity", but it would appear as though nothing is being sent from my web2py application.

Is anything being put in the web2py error logs?

You might find some useful information on this Google page. I believe you can turn off the "suspicious activity" alerts by going to the Details link next to the Last account activity line at the bottom-right of any Gmail page - in the window that pops up, go to the bottom and click change next to Alert Preference and select Never.

However, I've no idea if disabling the alerts will alter whether other IPs are allowed access, or whether it just doesn't warn you about it when they're denied.