教程地址:http://www.liaoxuefeng.com/wiki/001374738125095c955c1e6d8bb493182103fac9270762a000
# -*- coding:utf-8 -*-
from email.mime.text import MIMEText
msg = MIMEText('hello,send by python..','plain','utf-8')
# 输入Email地址和口令:
from_addr = raw_input('From:')
password = raw_input('Password:')
# 输入SMTP服务器地址:
smtp_server = raw_input('SMTP server:')
# 输入收件人地址:
to_addr = raw_input('To:')
import smtplib
server = smtplib.SMTP(smtp_server,25)#SMTP默认端口25
server.set_debuglevel(1)
server.login(from_addr,password)
server.sendmail(from_addr,[to_addr],msg.as_string())
server.quit()