I have a firebase function which I use as a webhook for sendgrid's inbound parse webhook. So that means whenever an email is sent to my domain, it calls the webhook. I know the webhook is being called, but I can't get to the data being sent by Sendgrid. This link states that all the information (text, sender, ect) should be right there in the headers. However when I print out req.headers
I get this:
{ host: 'us-central1-project-name.cloudfunctions.net',
'user-agent': 'Sendlib/1.0 server.sendgrid.net',
'transfer-encoding': 'chunked',
'content-type': 'multipart/form-data; boundary=xYzZY',
forwarded: 'for="ip";proto=https',
'function-execution-id': 'id',
'x-appengine-city': '?',
'x-appengine-citylatlong': '0.000000,0.000000',
'x-appengine-country': 'US',
'x-appengine-default-version-hostname': ~~~~~~~~~~~~~.appspot.com',
'x-appengine-https': 'on',
'x-appengine-region': '?',
'x-appengine-request-log-id': 'super-long-id',
'x-appengine-user-ip': 'ip',
'x-cloud-trace-context': 'id/number;o=1',
'x-forwarded-for': 'ip',
'x-forwarded-proto': 'https',
'accept-encoding': 'gzip',
connection: 'close' }'
(Obviously I replaced all the ID's and everything)
Where is the email information? I have tried doing all of the following and none of them produced any information regarding the email.
exports.reciever = functions.https.onRequest((req, res) => {
try {
console.log("Email recieved");
console.log(req);
console.log(req.headers);
console.log(req.header.to);
console.log(req.body);
console.log(req.get('to'));
console.log(req.body.to);
console.log(req.rawBody);
console.log(req.query);
console.log(req.query.to);
console.log(req.params);
console.log(req.path);
console.log(req.rawBody);
} catch (e) {}
finally {
res.send("2xx");
}
})