1
使用Mailgun发送电子邮件,b收到电子邮件后回复a.If我想跟踪来自b的电子邮件,我如何获取电子邮件? 下面是代码:可以通过使用Mailgun获取传入消息吗?
1.sendmail.py
from smtplib import SMTP
import requests
login_name = "[email protected]"
password = "********"
def send_message_via_smtp():
smtp = SMTP("smtp.mailgun.org", 587)
smtp.login(login_name, password)
smtp.sendmail("[email protected]","[email protected]", "Subject:mailgun test \n\n just for test.\n\n")
smtp.quit()
if __name__=="__main__":
send_message_via_smtp()
2.create_route.py
import requests
from werkzeug.datastructures import MultiDict
def create_route():
return requests.post(
"https://api.mailgun.net/v2/routes",
auth=("api", "key-9c4-t2q6fouilngjummvtv1rge7t00f2"),
data=MultiDict([("priority", 1),
("description", "Sample route"),
("expression", "match_recipient('.*@qq.com')"),
("action", "forward('[email protected]')"),
("action", "stop()")])
)
我创建路由和我运行该脚本sendmail.py.After人谁使用电子邮件[email protected]回复使用电子邮件[email protected]的其他人,Gmail 无法使用Mailgun方法'forward'接收邮件。 有谁能告诉我为什么?
我检查了Gmail的垃圾邮件,仍然是整个Gmail邮箱,但我看不到它!在脚本sendmail.py中将电子邮件地址“[email protected]”更改为“[email protected]”后,将表达式“match_recipient('。* @ qq.com')”更改为“match_recipient(')。 *@zzb.mailgun.org')“,它的工作! – ZZB 2013-03-08 03:47:08