Automatically send mail-2017-7-5

Source: Internet
Author: User
#coding =utf-8
'''
Created on 2017-7-5
@auther: Qigege
Project:Send a mailbox test

'''
Import Smtplib
From Email.mime.textImport Mimetext

#SMTPServer
mail_host=' Smtp.163.com '
Mail_user=' ******@163.com '
#NetEase mailbox for the web version, need to use the client password, enter the Web version of the mailbox to set the authorization code, that is, the client password
mail_password='******'

#Sender Mailbox
Sender=' ******@163.com '
#Recipient mailbox
receiver=[' ****** @qq. com ',' ****** @qq. com ']

Content=UMailbox Test......'#Content
title=' Python SMTP Mail Test '#Theme
Message=mimetext (Content,' Plain ',' Utf-8 ')
#Mailbox Sender Address
#formatting stringsFormat (), {}==%Cases:' {1},{0},{1} '. Format (' abc ', ' + ')--' 12,abc,12 '
message[' From ']=' {} '. Format (sender)
#Message recipient address, string list[‘Accept Address1 ',‘Accept Address2 ',......]Or‘Accept Address’
message[' To ']=', '. Join (receiver)#type (message[' to '])ForStr
message[' Subject ']=title

Try
#EnableSsl, the port is generally465
Smtpobj=smtplib. Smtp_ssl (Mail_host,465)
#Login Verification
Smtpobj.login (Mail_user,mail_password)
#Send
Smtpobj.sendmail (sender,receiver , message.as_string ())
#as_string () will mimetext or mimemultipart object converted to str
print " Mail has been send successfully .'
except smtplib. Smtpexception as e:
print e
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.