GH1995 / articles

blog
https://gh1995.github.io
2 stars 0 forks source link

Python 电子邮件 #21

Open GH1995 opened 4 years ago

GH1995 commented 4 years ago

SMTP 发送邮件

#!/usr/bin/env python3
# coding: utf-8

from email.mime.text import MIMEText
import smtplib

msg = MIMEText("hello, send by Python ...")

from_addr = "postmaster@mg.iruc.live"
password = "b2480ce531e7be2de3a0f1a6132900a"

to_addr = "tulingjiaoyu@126.com"

server = smtplib.SMTP("smtp.mailgun.org", 587)
server.set_debuglevel(1)
server.login(from_addr,password)
server.sendmail(from_addr, [to_addr], msg.as_string())
server.quit()

image

发送HTML邮件 image 发送附件 image image image image

GH1995 commented 4 years ago

POP3收取邮件

通过POP3下载邮件

image

解析邮件

image image

image