PYTHON CƠ BẢN - RẤT LÀ CƠ BẢN - Trang 86

from sender import Mail, Message

mail

=

Mail(

"smtp.gmail.com"

,

port

=

465

,

username

=

"[email protected]"

,

password

=

"yourpassword"

,

use_tls

=

False

,

use_ssl

=

True

,

debug_level

=

False

)

msg

=

Message(

"msg subject"

)

msg.fromaddr

=

(

"Vo Duy Tuan"

,

"[email protected]"

)

msg.to

=

"[email protected]"

msg.body

=

"this is a msg plain text body"

msg.html

=

"<b>this is a msg text body</b>"

msg.reply_to

=

"[email protected]"

msg.charset

=

"utf-8"

msg.extra_headers

=

{}

msg.mail_options

=

[]

msg.rcpt_options

=

[]

# Send message

mail.send(msg)