小编Qri*_*ila的帖子

Mailgun webhook POST机身似乎是空的

我试图处理来自Mailgun bounce webhook的http帖子消息.当将其发送到Mailgun的Postbin服务时,当然会找到所有数据.但我现在将POST发送到我的localhost服务器进行开发,我得到的只是空的json数组.我使用Test Webhook.

除了我们的主要服务之外,意图是保持这种简单.那是因为我开始使用nodejs/expressjs创建独立的webservice作为中继来接收来自Mailgun的电子邮件退回的POST消息,并通知管理员有关退回的电子邮件地址.

现在我无法弄清楚为什么我没有获得与Postbin中可见的数据相同的数据.

var express = require('express');
var app = express();
var bodyParser = require('body-parser');
var mailgun = require('mailgun-js')({apiKey: 'key-...', domain: 'mymailgundomain.com'});

app.use(bodyParser.urlencoded({
  extended: true
}));

function router(app) {
  app.post('/webhooks/*', function (req, res, next) {
    var body = req.body;

    if (!mailgun.validateWebhook(body.timestamp, body.token, body.signature)) {
      console.error('Request came, but not from Mailgun');
      res.send({ error: { message: 'Invalid signature. Are you even Mailgun?' } });
      return;
    }

    next();
  });

  app.post('/webhooks/mailgun/', function (req, res) {
    // actually handle request here
    console.log("got …
Run Code Online (Sandbox Code Playgroud)

webhooks node.js mailgun

14
推荐指数
2
解决办法
2423
查看次数

标签 统计

mailgun ×1

node.js ×1

webhooks ×1