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",
});
}
call stack extract:

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
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 constructorimplementation:
api endpoint call:
call stack extract:

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