Initial commit: redefined-designs storefront
This commit is contained in:
Executable
+24
@@ -0,0 +1,24 @@
|
||||
import nodemailer from 'nodemailer';
|
||||
|
||||
const transporter = nodemailer.createTransport({
|
||||
host: process.env.SMTP_HOST || 'smtp.gmail.com',
|
||||
port: parseInt(process.env.SMTP_PORT || '465', 10),
|
||||
secure: process.env.SMTP_SECURE !== 'false',
|
||||
auth: {
|
||||
user: process.env.SMTP_USER,
|
||||
pass: process.env.SMTP_PASSWORD
|
||||
}
|
||||
});
|
||||
|
||||
export async function sendMail(to: string, subject: string, html: string): Promise<void> {
|
||||
if (!process.env.SMTP_USER || !process.env.SMTP_PASSWORD) {
|
||||
console.warn(`SMTP not configured — skipping email to ${to}: "${subject}"`);
|
||||
return;
|
||||
}
|
||||
await transporter.sendMail({
|
||||
from: process.env.SMTP_FROM || process.env.SMTP_USER,
|
||||
to,
|
||||
subject,
|
||||
html
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user