2

I sent an email with the following python code:

import yagmail, sha, sys, os
os.system('stty -echo')
password = raw_input('Gmail password: ')
os.system('stty echo')
print ''
if not sha.sha(password).hexdigest() == 'digest_of_the_password':
    print 'Password Declined'
    sys.exit()
yag = yagmail.Connect('me@gmail.com', password)
yag.send('to@example.com', 'Hi', "G'day")

The subject came out as 'Hi', but the body came out 'RydkYXk='. I installed yagmail with the command: sudo pip install yagmail in my mac terminal.

How do I fix this error?

Will
  • 1,124
  • 12
  • 33

1 Answers1

2

I'm terribly sorry as the maintainer!

I accidentally added a tab in the wrong line, which added the base64 encoding also to text!

If you would now use sudo pip install -U yagmail it will upgrade to the new version where this has been resolved.

For future bugs, please file them at github, I will try to resolve all issues within 24 hours from posting.

Note that now you can simply omit the password: it will save it safely in the keyring after prompting you for the password once. That would save you many lines in this case:

import yagmail
yag = yagmail.SMTP('me@gmail.com')
yag.send('to@example.com', 'Hi', "G'day")
PascalVKooten
  • 20,643
  • 17
  • 103
  • 160