首页 > 代码库 > Python发送邮件

Python发送邮件

from email.mime.text import MIMEText
import smtplib

smtp_server = input(SMTP server:)
server = smtplib.SMTP(smtp_server, 25)
server.set_debuglevel(1)
from_addr = input(From:)
password = input(Password:)
to_addr = input(To:)
server.login(from_addr, password)

msg = MIMEText(hello, send by python..., plain, utf-8)
msg[From] = from_addr

server.sendmail(from_addr, [to_addr], msg.as_string())
server.quit()

 

Python发送邮件