'from' parameter is missing
See original GitHub issueI added mailgun-js to my project today, and have a problem sending messages.
My send code looks like this:
const data = {
from: "Mailgun Sandbox <postmaster@mail.optimiser.io>",
to: "derek@optimiser.io",
subject: "Hello",
template: "invite-client",
'h:X-Mailgun-Variables': JSON.stringify({test: "test"})
};
console.log('Data: ', data);
let result;
try {
const x = this.mailgunApi.messages.create(domain, data);
result = await x;
} catch (e) {
console.error('Failed sending email: ', e);
throw e;
}
return result;
I’m getting a 400 error back from the server and it is logging the following:
Failed sending email: [Error: BAD REQUEST] {
status: 400,
details: "'from' parameter is missing"
}
It looks like the form data isn’t being appended properly. After digging around for a while, I found a similar issue in the form-data github repo.
https://github.com/form-data/form-data/issues/478
So far I’ve tried upgrading form-data from 2.5.1 to 3.0.0, but still no luck.
It seems like in the previous version of mailgun-js, another library (popsicle) was used for managing the form data request parameters.
(On further digging, popsicle 1.4.0 just used form-data anyways.)
Since the mailgun-js 3.0.0 postMulti() uses the new keyword, it doesn’t look like I’ll be able to use popsicle the way it was used in the 2.0.6 release.
I’m going to try to revert to the previous version of mailgun-js in the meantime.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:5 (1 by maintainers)
Top GitHub Comments
This library is making it almost impossible to use. First of all the documentation within the mailgun app is obsolete. It’s using the older
mailgun-js
client. Trying to use this client from nodejs runs into so many other errors. Finally got stuck with the above oneI’ve been trying to access this API from mailgun, it seems the documentation is a bit misleading. when using https://api.mailgun.net/v3/xxxxx.domain/messages it seems that the body should be in a form of params for the API to recognize it.