kootenpv / yagmail

Send email in Python conveniently for gmail using yagmail
MIT License
2.66k stars 265 forks source link

yagmail fails when smtplib triumphs #34

Closed jgamedev closed 8 years ago

jgamedev commented 8 years ago

Ran this code and got the dreadful SMTPAuthenticationError:

import yagmail
yag = yagmail.SMTP('xx@gmail.com', 'xx')
contents = ['This is the body text']
yag.send('xx@hotmail.com', 'subject', contents)

If I replace the contents of the file with plain smtplib code, it works great: http://pastie.org/private/f4vbuy9ivcioqiutwbg

Ouch!! Now somebody tell me why :-)

Disclamer: Evrything has been taken care on gmail side to allow access, that's why smtplib works, btw

kootenpv commented 8 years ago

You're right. I introduced a bug in the latest version (v131), I will try to fix asap. Thanks for filing the issue!

kootenpv commented 8 years ago

Embarrassing. It is now fixed, thanks again. Use pip install -U yagmail to get the latest version (v132) going.

jgamedev commented 8 years ago

It works!! Email is sent and sky kittens are happy again.

But it printed this to the command line, is it expected?

2016-03-25 22:32:17 [yagmail] [ERROR] : Sending as text email since lxml is not installed

kootenpv commented 8 years ago

That doesn't look friendly. The idea is that everything will be HTML emails, with automatically an alternative view for just pure "text email" readers. You can also force sending pure text emails. But actually, HTML is nice :)

This error message is about the fact that lxml would like to try to parse the text as html, but it cannot, since it is not installed.

What I realise is that it would be better to use a builtin HTML parser not to have it as a dependency; created an issue (https://github.com/kootenpv/yagmail/issues/35). In your case, you can do 2 things. Ignore the error and only send text emails (note that you can then not use

contents="<h1>Title here</h1> Body here <a href="http://example.com"> Link here </a>"

Or install lxml which is a great module on its own.

Sorry for the inconvenience.

jgamedev commented 8 years ago

Cool, thank you so much for the fast response and for making this available to the community.

kootenpv commented 8 years ago

I removed lxml as a requirement!