Python Send mail

Source: Internet
Author: User

Calling third-party mailboxes using Python bulk mail third-party mail needs to set the authorization code here is 163 mailbox, the map cannot be uploaded. Set ===> mailbox security Settings ===> client authorization Password Code section: #!/usr/bin/env python#__*__coding:utf-8__*__import smtplibfrom  email.mime.text import MIMEText as mimetextfrom email.mime.multipart  import mimemultipart# Outgoing mail server address mail_host =  ' smtp.163.com ' #发件邮箱地址sender_user  =  ' [email  protected] ' #mail_pass  =  ' xxxxx ' #登录密码 # Email Authorization code, not login password sender_pass =  ' xxxx ' # Email address receivers = [' [email protected] ', ' [email protected] '] #邮件内容message  =  Mimetext (' python  mail test sent ', ' plain ', ' utf-8 ') #发送邮箱地址message [' From '] = sender_user# send an error when sending a message message[' To '] does not support lists, use the Join function to compound the address string message[' to '] =   ",". Join (receivers) #邮件主题subject  =  ' Python  SMTP  Mail test ' message[' Subject '] = subject# try:#     smtpobj  = smtplib. SMTP () #     smtpobj.connect (mail_host,25) #   &nbSp; smtpobj.login (Mail_user,mail_pass) #     smtpobj.sendmail (Sender,receivers, message) #     print  ' mail sent successfully ' # except:#     print   "Mail send Failed" smtpobj = smtplib. SMTP () smtpobj.connect (mail_host,25) smtpobj.login (sender_user,sender_pass) smtpobj.sendmail (Sender_user, Receivers,message.as_string ()) Smtpobj.close ()


This article is from the "LINUX" blog, so be sure to keep this source http://wangpengtai.blog.51cto.com/3882831/1950887

Python Send mail

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.