使用Javascript发送带有Mailgun的电子邮件

时间:2014-06-11 10:02:53

标签: javascript rest sendmail mailgun

我正在使用JS,我有以下代码:

  var XHRResponse = XHR.send("POST", "https://api.mailgun.net/v2/sandbox224f28ae45a8499d84184fd4c48e62ee.mailgun.org/messages",{
    "parameters": {
      "from": "Mailgun Sandbox <postmaster@sandbox224f28ae45a8499d84184fd4c48e62ee.mailgun.org>",
      "to": "Jordi <myname@gmail.com>",
      "subject": "Hello Jordi",
      "text": "Congratulations Jordi, you just sent an email with Mailgun!  You are truly awesome!  You can see a record of this email in your logs: https://mailgun.com/cp/log .  You can send up to 300 emails/day from this sandbox server.  Next, you should add your own domain so you can send 10,000 emails/month for free."
    }
  }); 

我需要使用apikey进行身份验证,但我不知道在哪里以及如何使用。

由于

1 个答案:

答案 0 :(得分:9)

Mailgun API文档包含所有这些信息。请具体查看“身份验证”部分http://documentation.mailgun.com/api-intro.html#authentication。然而,话虽如此,如果他们正确理解,我不会在客户端运行它,并且要求密钥以纯文本形式写入。