I'm a yagmail developer, a package that tries to make sending emails easier.
You can use the following code:
import yagmail yag = yagmail.SMTP(' me@gmail.com ', 'mypassword') for i in range(20): message += " " * 50 message += "<br/>" yag.send(contents = message)
Please note that by default it will send an HTML message and automatically add an alternative part for browsers without HTML.
Also note that when omitting subject an empty object will remain, and without the argument to it will send it to itself.
Also, note that if you configured yagmail correctly, you can simply log in using yag.SMTP() without having a username and password in the script (itβs still safe). If you pass the password, the message getpass .
Adding an attachment is as simple as pointing to a local file, for example:
yag.send(contents = [message, 'previously a lot of whitespace', '/local/path/file.zip']
Amazing right? Thanks for letting me show you a good use case for yagmail :)
If you have any suggestions, problems or ideas, please let me know on github .
PascalVKooten
source share