python 163郵箱發(fā)郵件

#!/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="測試標(biāo)題"#郵件標(biāo)題

words="測試正文"#郵件正文

smtpserver='smtp.163.com'

msg=MIMEText(words, 'plain', 'utf-8')#中文需參數(shù)‘utf-8',單字節(jié)字符不需要

msg['Subject'] = Header(subject, 'utf-8')#郵件標(biāo)題

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ā)送成功!"

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容