1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
from email.mime.text import MIMEText
from twisted.internet.task import react
from twisted.mail.smtp import sendmail
def main(reactor):
me = "alice@gmail.com"
to = ["bob@gmail.com", "charlie@gmail.com"]
message = MIMEText("This is my super awesome email, sent with Twisted!")
message["Subject"] = "Twisted is great!"
message["From"] = me
message["To"] = ", ".join(to)
d = sendmail(
"smtp.gmail.com",
me,
to,
message,
port=587,
username=me,
password="*********",
requireAuthentication=True,
requireTransportSecurity=True,
)
d.addBoth(print)
return d
react(main)
|