1. 程式人生 > >實現Python代碼發送郵件

實現Python代碼發送郵件

col smtplib mime nbsp sendmai RM add lib SM


import
smtplib from email.mime.text import MIMEText from email.utils import formataddr msg = MIMEText(郵件內容, plain, utf-8) msg[From] = formataddr(["jassin", [email protected]]) # 來自於哪裏 msg[To] = formataddr(["xxx", [email protected]]) # 發送於 msg[Subject] = "Pytohn開發面試邀請" # 主題
server = smtplib.SMTP("smtp.163.com", 25) server.login("[email protected]", "xxx") # 郵箱 賬戶密碼 server.sendmail([email protected], [[email protected], ], msg.as_string()) server.quit()

實現Python代碼發送郵件