fix(mail): bypass payload mail adapter and use standalone nodemailer
Some checks failed
🚀 Build & Deploy / 🔍 Prepare (push) Successful in 6s
🚀 Build & Deploy / 🧪 QA (push) Failing after 40s
🚀 Build & Deploy / 🏗️ Build (push) Successful in 12m4s
🚀 Build & Deploy / 🚀 Deploy (push) Has been skipped
🚀 Build & Deploy / 🧪 Post-Deploy Verification (push) Has been skipped
🚀 Build & Deploy / 🔔 Notify (push) Successful in 2s
Some checks failed
🚀 Build & Deploy / 🔍 Prepare (push) Successful in 6s
🚀 Build & Deploy / 🧪 QA (push) Failing after 40s
🚀 Build & Deploy / 🏗️ Build (push) Successful in 12m4s
🚀 Build & Deploy / 🚀 Deploy (push) Has been skipped
🚀 Build & Deploy / 🧪 Post-Deploy Verification (push) Has been skipped
🚀 Build & Deploy / 🔔 Notify (push) Successful in 2s
This commit is contained in:
@@ -8,6 +8,7 @@ import {
|
|||||||
ConfirmationMessage,
|
ConfirmationMessage,
|
||||||
} from "@mintel/mail";
|
} from "@mintel/mail";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
import nodemailer from "nodemailer";
|
||||||
|
|
||||||
export async function POST(req: Request) {
|
export async function POST(req: Request) {
|
||||||
const services = getServerAppServices();
|
const services = getServerAppServices();
|
||||||
@@ -77,7 +78,7 @@ export async function POST(req: Request) {
|
|||||||
services.errors.captureException(payloadError, { phase: "payload_save" });
|
services.errors.captureException(payloadError, { phase: "payload_save" });
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. Email sending via Payload (which uses configured nodemailer)
|
// 2. Email sending via standalone Nodemailer (bypassing Payload adapter)
|
||||||
try {
|
try {
|
||||||
const { config } = await import("@/lib/config");
|
const { config } = await import("@/lib/config");
|
||||||
const clientName = "MB Grid Solutions";
|
const clientName = "MB Grid Solutions";
|
||||||
@@ -92,7 +93,17 @@ export async function POST(req: Request) {
|
|||||||
? recipients.join(",")
|
? recipients.join(",")
|
||||||
: process.env.CONTACT_RECIPIENT || "info@mb-grid-solutions.com";
|
: process.env.CONTACT_RECIPIENT || "info@mb-grid-solutions.com";
|
||||||
|
|
||||||
logger.info("Preparing to send notification email", { to });
|
logger.info("Instantiating standalone nodemailer transport");
|
||||||
|
const transporter = nodemailer.createTransport({
|
||||||
|
host: config.mail.host,
|
||||||
|
port: config.mail.port,
|
||||||
|
auth: {
|
||||||
|
user: config.mail.user,
|
||||||
|
pass: config.mail.pass,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
logger.info("Preparing to send notification email", { to, host: config.mail.host });
|
||||||
|
|
||||||
// 2a. Notification to MB Grid
|
// 2a. Notification to MB Grid
|
||||||
const notificationHtml = await render(
|
const notificationHtml = await render(
|
||||||
@@ -104,7 +115,7 @@ export async function POST(req: Request) {
|
|||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
await payload.sendEmail({
|
await transporter.sendMail({
|
||||||
from: config.mail.from,
|
from: config.mail.from,
|
||||||
to,
|
to,
|
||||||
replyTo: email,
|
replyTo: email,
|
||||||
@@ -121,7 +132,7 @@ export async function POST(req: Request) {
|
|||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
await payload.sendEmail({
|
await transporter.sendMail({
|
||||||
from: config.mail.from,
|
from: config.mail.from,
|
||||||
to: email,
|
to: email,
|
||||||
subject: `Ihre Kontaktanfrage bei ${clientName}`,
|
subject: `Ihre Kontaktanfrage bei ${clientName}`,
|
||||||
|
|||||||
Reference in New Issue
Block a user