Hi everyone,
Please I need help with an issue. I’m not sure what the issue is. I believe it might be an SSL error, I have tried using Domain Management renew certificate to renew certificate.
It works perfectly fine in development. Please any help would be useful.
Thanks in advance
link: https://leye.dev/contact
Error:
utils/sendEmail.ts
"use server";
import SMTPTransport from "nodemailer/lib/smtp-transport";
import nodemailer from "nodemailer";
import Mail from "nodemailer/lib/mailer";
import { ENV } from "@/lib/env";
const transporter = nodemailer.createTransport({
host: ENV.BREVO_MAIL_HOST,
port: ENV.BREVO_MAIL_PORT,
secure: ENV.NODE_ENV !== "development",
auth: {
user: ENV.BREVO_MAIL_USER,
pass: ENV.BREVO_MAIL_PASSWORD,
},
} as SMTPTransport.Options);
type SendEmailProps = {
name: string;
email: string;
message: string;
subject: string;
budget: string;
timescale: string;
hon1?: string;
hon2?: string;
sender: Mail.Address;
recipients: Mail.Address | Mail.Address[];
};
export const sendEmail = async (EmailData: SendEmailProps) => {
const {
name,
email,
message,
subject,
budget,
timescale,
sender,
recipients,
} = EmailData;
const mailOptions = {
from: sender,
to: recipients,
subject,
message: message,
text: `Name: ${name}\nEmail: ${email}\nMessage: ${message}\nBudget: ${budget}\nTimescale: ${timescale}`,
html: `
<h2><b>Name:</b> ${name}</h2>
<p><b>Email:</b> ${email}</p>
<p><b>Message:</b> ${message}</p>
<p><b>Budget:</b> ${budget}</p>
<p><b>Timescale:</b> ${timescale}</p>
`,
};
try {
const info = await transporter.sendMail(mailOptions);
console.log("Email sent: ", info.response);
return { message: "Email sent successfully", info: info };
} catch (error: any) {
console.error("(utils/sendEmail)Error sending email: ", error);
throw new Error(`(utils/sendEmail) Failed to send email: ${error.message}`);
}
};