Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TransformStream is not defined #262

Closed
Qlipoth opened this issue Apr 9, 2022 · 4 comments
Closed

TransformStream is not defined #262

Qlipoth opened this issue Apr 9, 2022 · 4 comments

Comments

@Qlipoth
Copy link

Qlipoth commented Apr 9, 2022

Hello, I use this package with Next.js. const Mailgun = require('mailgun.js'); breaks my app. There is an error ReferenceError: TransformStream is not defined error How can i fix it?

Node version: v16.14.2
Next.js: 12.1.1
OS: Win 10

@olexandr-mazepa
Copy link
Collaborator

Hi @Qlipoth
I am not an expert on Next.js but today I tried to set up a small app via generator and this app has successfully sent an email.
Could you provide a code snippet where I will be able to see how you use SDK?
It would be awesome if you could make some test app that reproduces an issue but if not code snippet is also fine.

@Qlipoth
Copy link
Author

Qlipoth commented Apr 18, 2022

Hi @Qlipoth I am not an expert on Next.js but today I tried to set up a small app via generator and this app has successfully sent an email. Could you provide a code snippet where I will be able to see how you use SDK? It would be awesome if you could make some test app that reproduces an issue but if not code snippet is also fine.

Hello. I refused using this package in favor of an older version of it: mailgun-js and it works properly. I created file: pages -> api -> mail.js My code snippet:

const { MAILGUN_API_KEY, MAILGUN_DOMAIN, MAILGUN_URL, FROM_EMAIL_ADDRESS, CONTACT_TO_EMAIL_ADDRESS } = process.env;
const mailgun = require('mailgun-js')({ apiKey: MAILGUN_API_KEY, domain: MAILGUN_DOMAIN, url: MAILGUN_URL });
export default async function testMail(req, res) {
try {
const { email, description, name } = req.body;
const mailgunData = {
from: FROM_EMAIL_ADDRESS,
to: CONTACT_TO_EMAIL_ADDRESS,
subject: 'new message from ${email}',
text: ${name}: ${description || "description"},
};
await mailgun.messages().send(mailgunData);
res.status(200).json({ status: 'Ok' });
} catch (err) {
console.error(err);
}
}

@olexandr-mazepa
Copy link
Collaborator

olexandr-mazepa commented Apr 18, 2022

Hi @Qlipoth I am not an expert on Next.js but today I tried to set up a small app via generator and this app has successfully sent an email. Could you provide a code snippet where I will be able to see how you use SDK? It would be awesome if you could make some test app that reproduces an issue but if not code snippet is also fine.

Hello. I refused using this package in favor of an older version of it: mailgun-js and it works properly. I created file: pages -> api -> mail.js My code snippet:

const { MAILGUN_API_KEY, MAILGUN_DOMAIN, MAILGUN_URL, FROM_EMAIL_ADDRESS, CONTACT_TO_EMAIL_ADDRESS } = process.env; const mailgun = require('mailgun-js')({ apiKey: MAILGUN_API_KEY, domain: MAILGUN_DOMAIN, url: MAILGUN_URL }); export default async function testMail(req, res) { try { const { email, description, name } = req.body; const mailgunData = { from: FROM_EMAIL_ADDRESS, to: CONTACT_TO_EMAIL_ADDRESS, subject: 'new message from ${email}', text: ${name}: ${description || "description"}, }; await mailgun.messages().send(mailgunData); res.status(200).json({ status: 'Ok' }); } catch (err) { console.error(err); } }

Of course, it is your choice, but I would not recommend you to use mailgun-js package.
It is deprecated and has security vulnerabilities.
image

mailgun/mailgun-js-boland#269
mailgun/mailgun-js-boland#266

@olexandr-mazepa
Copy link
Collaborator

I am closing this issue.
Feel free to create a new one if you decide to use mailgun.js and will have an issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants