Send email using python

Source: Internet
Author: User

Import Smtplib fromemail.mime.text Import Mimetextdef SendEmail (): Email=""#设置收件地址 mailto_list=[email] mail_host=""#设置服务器 Mail_user=""#用户名 Mail_pass=""#口令 msg=""#Email内容 Msssageg= Mimetext (msg,_subtype='HTML', _charset='gb2312') #创建一个实例, this is set to HTML-formatted message msssageg['Subject'] =""#设置主题 msssageg[' from'] =""#发件地址 msssageg[' to'] =";". Join (mailto_list)Try: S=Smtplib. SMTP () s.connect (mail_host) #连接smtp服务器 s.login (mail_user,mail_pass) #登陆服务器 s.sendmail (Mail_user, MA Ilto_list, Msssageg.as_string ()) #发送邮件 s.close ()returnTrue except Exception, E:print str (e)returnFalseif__name__ = ="__main__": SendEmail ();

Send email using python

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.