Forums

getpass warning with yagmail

I use yagmail to send mails from a gmail account. My script worked well last time i checked (i admit it was a few months ago, possibly end of last year). I tried it now and it's not working anymore, with a few issues linked to the gmail account. I allowed for 'less secure apps' to access on gmail side (i'm pretty it used to be on, but looks like i had to put it again). But then the error log told me i had to 'log in from a browser'. I resolved to update yagmail in my virtualenv, which in turn led me to install keyrings, in order to properly manage my login details. Keyrings did not suffice ('no recommended backend available' error), i had to install keyrings.alt.

The error i now get is :

/usr/lib/python3.8/getpass.py:91: GetPassWarning: Can not control echo on the terminal.
passwd = fallback_getpass(prompt, stream)
Warning: Password input may be echoed.
Password for <mymail@gmail.com>: Error running WSGI application
EOFError

I can't find what i'm supposed to do.

I found this page on stackoverflow. One of the answers says : "Use an actual terminal -- that is, an environment where stdin, stdout and stderr are connected to /dev/tty, or another PTY-compliant device. The IDLE REPL does not meet this requirement."

This makes me think the problem now comes from how I use pythonanywhere. Can someone give me some directions here ?

Where are you running your code? It looks like it just tries to prompt interactively for a password, it won't work if you're running it in a web app or a scheduled task.

Hi @pafk, my code is part of a website i am building. Basically as a user enter their details, emails are sent from my gmail account. So it is part of the web app, and it was working just fine during months. I don't know what happened since, if gmail changed their conditions, or if yagmail changed what it does.

By the way i just found this page on pythonanywhere

I had the error mentioned therein before i updated yagmail. Then the error changed when i updated yagmail.

You are not able to run the web app in the terminal as your StackOverflow link suggests.

...so yagmail is not useable anymore ? Is it yagmail's "fault" or pythonanywhere's fault? (in relation to google...) Or (hopefully) there's something wrong in my code that can be fixed :) ?

I tried creating an app-specific password, to no avail.

Your code should not rely on getting any interactive input.

Interactive? The user has to capture his details, which are processed in a database. Then emails are sent from my address, to several recipients. This entire process is the purpose of my web app, and used to work smoothly. I don't understand why this should not be possible anymore. Is there another way?

You will need to investigate why your code has started prompting for a password. It looks like it may be doing that because the first attempt failed, but that's just a guess.