import sys
import socket
import smtplib
server = 'smtp.163.com' #SMTP服务器
fromaddr = ******@***.com' #接收邮箱
toaddrs = '******@***.com.cn' #发送邮箱
message = """ To :%s
From:%s
Subject:Test Message
Hello""" % (','.join(toaddrs), fromaddr)
try:
s = smtplib.SMTP(server) #SMTP核心类
s.set_debuglevel(1)
s.login('******', '******') #SMTP认证
s.sendmail(fromaddr, toaddrs, message)
print 'Message successfylly sent to %d recipient(s)' % len(toaddrs)
except (socket.gaierror, socket.error, socket.herror, \
smtplib.SMTPException), e:
print 'Your message may not have been sent!'
print e
sys.exit(1)
Email - 发送邮件
最新推荐文章于 2024-05-21 10:09:37 发布