簡體   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