kootenpv / yagmail

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

Html tables getting deformed severly #177

Closed haritn closed 4 years ago

haritn commented 4 years ago

Sending html generated by pandas.DataFrame.to_html() shows up completely garbled in email. Used both as content as well as html. Looks like some processing going on in the background unnecessarily. Ultimately used simple smtplib.SMTP and worked just fine.

Hopeful this saves someone else countless hours and frustration figuring this out.

kootenpv commented 4 years ago

I suspect you should just add newline_to_break=False:

html = pd.DataFrame({"a": [1,2,3], "b": [1,2,3]}).to_html()
yag.send(contents=html, newline_to_break=False)
haritn commented 4 years ago

Thanks for the suggestion. I would recommend that this option be False by default. To me it doesn't make sense to change html with additional unwarranted tags by default.