繁体   English   中英

Mailgun HTTP错误代码400错误请求

[英]Mailgun HTTP error code 400 Bad Request

Mailgun给了我一个HTTP代码400,根据他们的文档,这意味着

错误的请求-通常缺少必需的参数https://documentation.mailgun.com/en/latest/api-intro.html#errors

我在firebase云功能中具有邮件发送功能,这是云功能

 app.post('/sendMail', (req, res) => { const data = { from: 'Excited User <me@samples.mailgun.org>', to: 'email, apikey', subject: 'Hello', text: 'Testing some Mailgun awesomness!' }; mailgun.messages().send(data, function (error, body) { if(error){ console.log(error); res.send(error) } console.log(body); res.send('sent email!') }); }); exports.app = functions.https.onRequest(app); 

我在我的应用程序内部将此函数称为应用程序内部的代码:

 sendEmail(){ let url = `URL to my cloud function`; let params: URLSearchParams = new URLSearchParams(); let data = { from: 'Excited User <me@samples.mailgun.org>', to: 'myEmail , apiKey', subject: 'Hello', text: 'Testing some Mailgun awesomness!' }; return this.http.post(url,data) .toPromise() .then(res=>{ console.log(`Res:`,res); }) .catch(err => { console.log('Error',err); }) } 

我遵循了firebase API https://documentation.mailgun.com/en/latest/quickstart-sending.html#send-via-api,我不知道缺少什么参数,因为我只是复制并粘贴了示例代码

我改变了这个

 const data = { from: 'Excited User <me@samples.mailgun.org>', to: 'email, apikey', subject: 'Hello', text: 'Testing some Mailgun awesomness!' }; 

至:

 const data = { from: 'me@samples.mailgun.org', to: 'email', subject: 'Hello', text: 'Testing some Mailgun awesomness!' }; 

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM