#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