python 发送电子邮件模块smtplib

#!/usr/bin/python
# -*- coding: utf-8 -*-

import smtplib
import string
HOST = "smtp.uinx.com.cn"
SUBJECT = "Test email from Python"
#TO = "[email protected]"
#TO = "[email protected]"
TO = "[email protected]"
FROM = "[email protected]"
text = "Pyhon rules them all!"
BODY = string.join((
"From:  %s" %FROM,
"To:   %s"  % TO,
"Subject:    %s" % SUBJECT,
" ",
text
),"\r\n")
server = smtplib.SMTP()
server.connect (HOST,"25")
#server.starttls()
server.login("[email protected]","ddddd@")
server.sendmail(FROM, [TO], BODY)
server.quit


你可能感兴趣的:(smtplib)