#!/usr/bin/python
import smtplib
import string
HOST = "mail.merit-link.com"
SUBJECT = "Test email from Python"
TO = "yaosx@merit-link.com"
FROM = "yaosx@merit-link.com"
text = "Python 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.login("yaosx","mypasswd") #注意此处是登录的用户名和密码
server.sendmail(FROM,[TO],BODY)
server.quit()
转载于:https://blog.51cto.com/yaoshixian/1963419