Python development [module]: send emails, and python development sends emails
Email
1. Simple Transmission
Import smtplibfrom email. mime. text import MIMETextfrom email. header import Headersender = 'lianzhilei0711 @ 163.com '# email sending account receiver = '192 @ qq.com' # multiple email receiving accounts are enclosed by tuples () subject = 'title' # mail title smtpserver = 'smtp .163.com '# send mail smtp address password = 'lzl1393009694' # Set msg = MIMEText ('mail test .. ', 'plain', 'utf-8') # use plain for the second parameter !! Do not use text !! Otherwise, the 554 error msg ['subobject'] = Header (Subject, 'utf-8') is reported ') # msg ['from'] = sender # Must be set # msg ['from'] = 'James <lianzhilei0711@163.com> 'msg ['to'] = Explorer # smtp must be set = smtplib. SMTP () smtp. connect ('smtp .163.com ') smtp. login (sender, password) smtp. sendmail (sender, receiver, msg. as_string () smtp. quit ()