feat(06-02): branded signing request email + mailer utilities
- Add SigningRequestEmail.tsx React Email component (navy/gold brand colors, CTA button) - Add signing-mailer.tsx with sendSigningRequestEmail() and sendAgentNotificationEmail() - Uses CONTACT_SMTP_* env vars (same SMTP provider as contact form) - Sender: "Teressa Copeland" <teressa@teressacopelandhomes.com>
This commit is contained in:
67
teressa-copeland-homes/src/lib/signing/signing-mailer.tsx
Normal file
67
teressa-copeland-homes/src/lib/signing/signing-mailer.tsx
Normal file
@@ -0,0 +1,67 @@
|
||||
import { render } from '@react-email/render';
|
||||
import nodemailer from 'nodemailer';
|
||||
import { SigningRequestEmail } from '@/emails/SigningRequestEmail';
|
||||
import React from 'react';
|
||||
|
||||
function createTransporter() {
|
||||
return nodemailer.createTransport({
|
||||
host: process.env.CONTACT_SMTP_HOST!,
|
||||
port: Number(process.env.CONTACT_SMTP_PORT ?? 587),
|
||||
secure: false,
|
||||
auth: {
|
||||
user: process.env.CONTACT_EMAIL_USER!,
|
||||
pass: process.env.CONTACT_EMAIL_PASS!,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export async function sendSigningRequestEmail(opts: {
|
||||
to: string;
|
||||
clientName?: string;
|
||||
documentName: string;
|
||||
signingUrl: string;
|
||||
expiresAt: Date;
|
||||
}): Promise<void> {
|
||||
const expiryDate = opts.expiresAt.toLocaleDateString('en-US', {
|
||||
month: 'long',
|
||||
day: 'numeric',
|
||||
year: 'numeric',
|
||||
});
|
||||
const html = await render(
|
||||
React.createElement(SigningRequestEmail, {
|
||||
documentName: opts.documentName,
|
||||
signingUrl: opts.signingUrl,
|
||||
expiryDate,
|
||||
clientName: opts.clientName,
|
||||
})
|
||||
);
|
||||
const transporter = createTransporter();
|
||||
await transporter.sendMail({
|
||||
from: '"Teressa Copeland" <teressa@teressacopelandhomes.com>',
|
||||
to: opts.to,
|
||||
subject: `Please sign: ${opts.documentName}`,
|
||||
html,
|
||||
});
|
||||
}
|
||||
|
||||
export async function sendAgentNotificationEmail(opts: {
|
||||
clientName: string;
|
||||
documentName: string;
|
||||
signedAt: Date;
|
||||
}): Promise<void> {
|
||||
const formattedTime = opts.signedAt.toLocaleString('en-US', {
|
||||
month: 'long',
|
||||
day: 'numeric',
|
||||
year: 'numeric',
|
||||
hour: 'numeric',
|
||||
minute: '2-digit',
|
||||
timeZoneName: 'short',
|
||||
});
|
||||
const transporter = createTransporter();
|
||||
await transporter.sendMail({
|
||||
from: '"Teressa Copeland Homes" <teressa@teressacopelandhomes.com>',
|
||||
to: 'teressa@teressacopelandhomes.com',
|
||||
subject: `Signed: ${opts.documentName}`,
|
||||
text: `${opts.clientName} has signed "${opts.documentName}" on ${formattedTime}.`,
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user