#!/usr/bin/python
# -*- coding: UTF-8 -*-
import os
import copy
import time
import sys
import urllib
import shutil
import smtplib
from email.mime.text import MIMEText
from email.header import Header
sender="xxx@163.com"#“我”的郵箱
password="xxx"#密碼
receiver="xxx@xx.com"#接收者郵箱
subject="測試標題"#郵件標題
words="測試正文"#郵件正文
smtpserver='smtp.163.com'
msg=MIMEText(words, 'plain', 'utf-8')#中文需參數(shù)‘utf-8'差油,單字節(jié)字符不需要
msg['Subject'] = Header(subject, 'utf-8')#郵件標題
msg['from'] = sender#發(fā)信人地址
msg['to'] = receiver#收信人地址
smtp=smtplib.SMTP()
smtp.connect('smtp.163.com')
smtp.login(sender, password)
smtp.sendmail(sender, receiver, msg.as_string())#這行代碼解決的下方554的錯誤
smtp.quit()
print"郵件發(fā)送成功!"