Open pelicanenglw opened 1 year ago
Nope, it seems that lib is abandoned. But you can use mailgun API directly, check answers in https://github.com/mailgun/mailgun.js/issues/341
Nope, it seems that lib is abandoned. But you can use mailgun API directly, check answers in #341
Thanks, I was already started down that road. It seems like the path of least resistance. It would be nice if Mailgun released a real data API rather than a form post.
Hello @pelicanenglw @nosovk
This SDK is officially supported by Mailgun, and I can't agree that its package is abandoned or doesn't work.
Yeap there are some places in docs that mention the old mailgun-js
package, but that package is outdated and has security issues.
Talking about the issue you mentioned, it definitely needs investigation but it mentions only nestjs
framework and should not influent you if you need SDK in another environment.
I am happy to help if you will have any issues regarding usage.
Also, I would like to say that this is an open-source repository as well so feel free to create a PR if you see areas for improvement.
Actually I don't see place where nestjs mentioned. Issues mentioned in chat are regarding running in Cloudflare workers, and regarding node18 native formdata (more issues in GitHub). Actually pull requests in a lib is mostly hanging for more than year... It doesn't look that lib is maintained, but the REST API is well documented, and there are no problems in using it directly.
Found issue with NestJS, it's related to typescript import, not to NestJS
Okay let's go one by one:
This library does not appear to work. (See form-data issue https://github.com/mailgun/mailgun.js/issues/339 form-data error)
It may be related to typescript import but it is more likely something wrong with the way of importing the form-data
package in the nestjs, just because importing into a simple TS app works fine.
form-data
package than SDK.just for information - according to https://github.com/mailgun/mailgun.js/issues/341#issuecomment-1416505938 this lib could work without FormData at all.
The same story with axios - it's not necessary to use it when we have undici, it's seems that accepting fetch instead of FormData could be good idea.
Unfortunately weekly downloading number not a sign of quality or support. It means that library used as a backbone in some popular dependencies, nothing more.
Regarding pulls - if they are irrelevant and should be closed - then why they exist? Isn't it a sign of not well maintained library?
In common I was able to fix my issue without lib (see comment attached) and now for me issue is not relevant.
Thanks for willing to support OSS, Mailgun is good product and I hope they will support maintaining good nodejs wrapper for their library.
The old library mailgun-js works fine, other than the security issues. The new one mailgun.js, certainly does not work in my testing (vanilla JS not TS). Using the form post api works correctly and this is what I ended up implementing. In general people are still being directed to -js both in docs and in forum posts. So this leads to a lot of confusion. The new library not working for some just adds to it. In my case the objects were correctly serialized by the form-data library but I did not spend more time on why it was generating the error in mailgun.js. The quicker path was talking directly to the mailgun API.
@pelicanenglw Happy to hear that you've resolved the issue. Could you add more details about the environment where the library didn't work for you, is it nodeJS or browser, which version, OS, etc? I am curious to reproduce/fix this case. Also, in case you have links to places where you saw links to the old package, please share them with me. I already know about a few of them from separate GitHub issues, but maybe you have seen other places.
@olexandr-mazepa we were using mailgun.js on the backend - Node v14.21.1. I only tested in my local environment (MacOS 12.5.1). The previous mailgun-js worked without issue.
@pelicanenglw It becomes more interesting 😃 I've just checked emails sent on the node v14.21.1 on mac os v12.6.3 and the SDK works fine.
This is the code example I used:
const YOUR_DOMAIN_NAME = 'domain';
const formData = require('form-data');
const Mailgun = require('mailgun.js');
const clientData = require('../client-options.json');
const mailgun = new Mailgun(formData);
const mailgunClient = mailgun.client(clientData);
const mailgunData = {
from: 'Excited User',
to: ['email address'],
subject: 'Hello',
text: 'Testing some Mailgun awesomness!',
html: '<h1>Testing some Mailgun awesomness!</h1>'
};
(async () => {
try {
const res = await mailgunClient.messages.create(YOUR_DOMAIN_NAME, mailgunData);
console.log(res);
} catch (error) {
console.log('error----------->', error);
}
})();
Are you see a difference from your code that you think may cost the issue?
The v8.0.6 gives me a "Module Not Found Error" because i'am importing it with require. Whilst this error when i hover on the require id, it displays the correct path dir to "/node_modules/mailgun.js/index.ts". I'am using Node v16.9.0.
I’m really confused…. The mailgun API docs were updated yesterday - Jan 30, 2023 and it still lists mailgun-js as the formally supported library. On the plus side it works but there are security issues with old dependencies.
This library does not appear to work. (See form-data issue #339 form-data error)
Does anyone have a working node example using this library?