2014-11-06 16 views
0

我想通過curl發送使用Mailgun API的電子郵件,我有一個html電子郵件,所以我所做的只是將HTML文本從給定樣本更改爲HTML。我添加了我的模板,但由於某種原因,我發現它不接受頭部和身體標籤,對吧?Mailgun API cURL使用HTML,它是否接受頭部和身體標記?

我與通訊鏈接,請幫我http://bit.ly/10B63PU

這裏文檔上的樣本代碼與API發送:

http://documentation.mailgun.com/quickstart-sending.html#send-via-api

回答

1

我學會了我不得不使用--form-string不只是用html替換文本。以下示例直接來自mailgun,然後才列出發送郵件的文本版本。

http://documentation.mailgun.com/api-sending.html#examples

curl -s --user 'api:key-3ax6xnjp29jd6fds4gc373sgvjxteol0' \ 
    https://api.mailgun.net/v2/samples.mailgun.org/messages \ 
    -F from='Excited User <[email protected]>' \ 
    -F to='[email protected]' \ 
    -F cc='[email protected]' \ 
    -F bcc='[email protected]' \ 
    -F subject='Hello' \ 
    -F text='Testing some Mailgun awesomness!' \ 
--form-string html='<html>HTML version of the body</html>' \ 
    -F [email protected]/cartman.jpg \ 
    -F [email protected]/cartman.png 
0

你需要指定的HTML有效載荷通過HTML否則它會認爲它是純文本。

curl -s --user 'api:key-3ax6xnjp29jd6fds4gc373sgvjxteol0' \ 
https://api.mailgun.net/v2/samples.mailgun.org/messages \ 
-F from='Excited User <[email protected]>' \ 
-F [email protected] \ 
-F [email protected] \ 
-F subject='Hello' \ 
-F text='Plain text version of my awesome newsletter' \ 
-F html='<body>My awesome newsletter</body>' 

謝謝你提出這個問題 - 它可能不那麼明顯!

+0

它可能適用於一些,但我的情況下,它不能正常工作,克里斯H.從mailgun使用HTML它需要輸入爲形式的字符串與捲曲表示。 – jkcoding 2014-12-30 04:52:21

+0

好思想! --form-string是最好的。 – 2014-12-30 17:20:43

相關問題