Reputation: 141
I'm trying to setup yagmail with an external .yagmail file with credentials but when I run the code it returns
YagInvalidEmailAddress: Emailaddress "yagmail.register('[email protected]', 'my.password')" is not valid according to RFC 2822 standards
the .yagmail file is like this
yagmail.register('[email protected]', 'my.password')
Any suggestion?
Upvotes: 0
Views: 1245
Reputation: 241
You should run the following once in python, which will store the registration in the backend (yagmail.register is just a wrapper around keyring lib functionality):
import yagmail
yagmail.register(email, pwd)
After this, you can just use the following in your script to start using yagmail:
yag = yagmail.SMTP(email)
yag.send()
If you want to omit the email as well, you can write your gmail address in the .yagmail file, which should reside in you $HOME directory.
Then, you could just use:
yag = yagmail.SMTP()
yag.send()
On some systems (CentOS for me), you also need to pip install keyrings.alt
and import keyrings
in your registration script.
Upvotes: 0