Send mail through code

 
1. E-mail application 126 or 163
 
2. Open Service + authorization code (open settings POP3 / SMTP services)
 
3. By transmitting the code
 
 
import smtplib
from email.mime.text import MIMEText
from email.utils import formataddr
 
# Write the content of the message
msg = MimeText ( 'Boss, I want to play the male lead, how you want the all right.' , 'Plain' , 'UTF-8' )
MSG [ 'the From' ] = formataddr ([ "gunner" , "account name @ 163.com ' ])
msg [ 'the To' ] = formataddr ([ "boss" , "your account name qq.com @ ' ])
msg [ 'Subject' ] = "Love director" ------> Title
 
Server = smtplib . SMTP_SSL ( "SMTP. mailbox type .com" , 465 )
Server . the Login ( "account name" , "xxxxxxx" ) # authorization code
Server . sendmail ( '163.com account name @' , [ 'qq.com your account name @' , ], msg . as_string ())
server.quit()

Guess you like

Origin www.cnblogs.com/yecanglan/p/11550633.html