使用mailgun发送电子邮件

时间:2018-11-12 10:26:44

标签: django mailgun django-mailgun

def send_complex_message():
    return requests.post(
         "https://api.mailgun.net/v3/YOUR_DOMAIN_NAME/messages",
         auth=("api", "YOUR_API_KEY"),
         files=[("attachment", ("test.jpg", open("files/test.jpg","rb").read())),
                ("attachment", ("test.txt", open("files/test.txt","rb").read()))],
         data={"from": "Excited User <YOU@YOUR_DOMAIN_NAME>",
             "to": "foo@example.com",
             "cc": "baz@example.com",
             "bcc": "bar@example.com",
             "subject": "Hello",
             "text": "Testing some Mailgun awesomness!",
             "html": "<html>HTML version of the body</html>"})

这是mailgun文档中的代码。 我需要在“ html”中访问“ text”的值。 有什么办法可以做到的吗?

0 个答案:

没有答案