question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

'from' parameter is missing

See original GitHub issue

I 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.

https://github.com/mailgun/mailgun-js/blob/25766b7e0abfb2fb88430ab80bb5f1fa9fec1d8a/lib/request.js#L125

(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:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
ShankarSumanthcommented, Jan 23, 2021

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 one

1reaction
JtawRobotcommented, Mar 8, 2022

I’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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

'from' parameter is missing · Issue #92 · mailgun ... - GitHub
I added mailgun-js to my project today, and have a problem sending messages. My send code looks like this: const data = {...
Read more >
RestClient mailgun error "message": "'from' parameter is ...
I am using RestClient in my rails app to send emails. The following Curl command works: curl -s "https://api:key-XYZ@api.mailgun.net/v2 ...
Read more >
What does “Parameter missing” mean? : r/Wattpad - Reddit
In programming, missing parameter means that you didn't input a value into the textbox (like username or password).
Read more >
Missing Parameter - Wish Merchant Help Center
This error occurred because the feed file you tried to upload contains one or more rows with missing information. Each row in your...
Read more >
Fix “Parameter Missing or Invalid” errors - Shopify.dev
When adding an item to the cart, you may have encountered the error Parameter Missing or Invalid: Required parameter missing or invalid.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found