-
Notifications
You must be signed in to change notification settings - Fork 235
TextEncoder is not a constructor error in nextjs server side api #332
Copy link
Copy link
Closed
Description
Hi,
I ran into an issue when implementing emailjs SMTPClient in a NextJs server side api.
the error:
TypeError: util__WEBPACK_IMPORTED_MODULE_3__.TextEncoder is not a constructor
implementation:
import { SMTPClient } from "emailjs";
export const emailClient = () =>
new SMTPClient({
user: process.env.EMAILJS_USER,
password: process.env.EMAILJS_PASSWORD,
host: process.env.EMAILJS_HOST,
ssl: true,
});
api endpoint call:
try {
const { email } = req?.body;
if (!email) {
return res.status(500)?.json({
message: "Missing email",
});
}
const client = emailClient();
const textConstruct = `bruderbau.hu kapcsolat felvétel üzenet:
${email.text}`;
const messageConstruct = `Üzenet ${email.from} feladótól, bruderbau.hu kapcsolat felvétel`;
const from = email.from;
const message = await client.sendAsync({
text: textConstruct,
from: from,
to: process.env.EMAILJS_DEFAULT_RECIPENT ?? "",
subject: messageConstruct,
});
return res.status(200)?.json({
message: message.text,
});
} catch (error) {
res.status(500)?.json({
message: "Error submitting email",
});
}
i want to release this feature to my client as soon as possible. please let me know if it`s something on my side, or more info needed. Also if no possibility of fixing it, so I look for an alternative solution.
Best regards,
Peter
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
