Import Smtplib
#from Email.mime.text Import Mimetext
From email. Mimetext Import Mimetext
def send_email (content):
Sender = "[email protected]"
receiver = [[email protected]]
Host = ' 220.181.12.16 '
Port = 465
msg = Mimetext (content)
Msg[' from '] = "[email protected]"
msg[' to ' = "[email protected]"
msg[' Subject ' = "Backup Check"
Try
SMTP = Smtplib. SMTP ()
Smtp.connect (' 220.181.12.16:25 ')
# Smtp.ehlo ()
# SMTP.STARTTLS ()
# Smtp.ehlo ()
# SMTP = Smtplib. Smtp_ssl (host, Port)
Smtp.login (sender, ' xxxx ')
Smtp.sendmail (sender, receiver, msg.as_string ())
# Getlog (). info ("Send email success")
Except Exception, E:
# Get_log (). Error (E)
print ' Email fail '
Print E
Pass
Send_email (' AAA ')
This article is from the "Automation Rolin" blog, so be sure to keep this source http://luoguoling.blog.51cto.com/1568501/1617114
python2.4 sending mail