【发布时间】:2015-11-26 01:26:19
【问题描述】:
按照 Mailgun 教程,我可以通过 Mailgun 使用 Python 中的请求库发送电子邮件。
我需要在 Python 中使用“httplib”(不是请求!)来发送电子邮件。但是,Mailgun 教程没有提供任何如何使用 httplib 的示例。
# this is a "requests" example from the Mailgun tutorial
requests.post(
"https://api.mailgun.net/v3/" + env.MG_SANDBOX_DOMAIN_NAME + "/messages",
auth=("api", env.MG_KEY),
files=[("attachment", open(my_PDF_full_path))],
data={
"from": "myemail@domain.com",
"to": "youremail@domain.com",
"subject": "TESTING EMAIL",
"text": "TESTING EMAIL",
"html": "<p>TESTING EMAIL</p"
}
)
如何将此示例转换为在 Python 中使用“httplib”库的代码?
【问题讨论】:
标签: python http-headers python-requests mailgun httplib