Page 86 - Python Cơ Bản
P. 86

from sender import Mail, Message



           mail = Mail(

               "smtp.gmail.com",

               port = 465,

               username = "example@gmail.com",

               password = "yourpassword",

               use_tls = False,

               use_ssl = True,

               debug_level = False

           )



           msg = Message("msg subject")

           msg.fromaddr = ("Vo Duy Tuan", "example@gmail.com")

           msg.to = "destuser@gmail.com"

           msg.body = "this is a msg plain text body"

           msg.html = "<b>this is a msg text body</b>"

           msg.reply_to = "example@gmail.com"

           msg.charset = "utf-8"

           msg.extra_headers = {}

           msg.mail_options = []

           msg.rcpt_options = []


           # Send message


           mail.send(msg)
   81   82   83   84   85   86   87   88   89   90   91