Skip to content

Commit

Permalink
update subject line, handle no message included
Browse files Browse the repository at this point in the history
  • Loading branch information
jakewheeler committed Feb 21, 2025
1 parent 1e5cdd1 commit 2b7e730
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/app/api/contact/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,16 @@ export async function POST(request: Request) {
type FormData = z.infer<typeof FormData>;
const reqData: FormData = data;

const baseSubjectLine = 'Website Contact Form - ';
const nameSubject = reqData.name ? `${reqData.name}, ` : '';
const orgSubject = reqData.organization ? `${reqData.organization}, ` : '';

const message: mailer.MailDataRequired = {
to: process.env.SEND_TO_EMAIL!,
from: process.env.SEND_FROM_EMAIL!, // This must be an authenticated SendGrid email
replyTo: reqData.email, // Reply to the original email provided
subject: `New Contact Form Submission`,
text: reqData.message ?? 'No message body provided.',
subject: baseSubjectLine + nameSubject + orgSubject + reqData.email,
text: reqData.message ?? '[No message provided]',
};

console.log(message);
Expand Down

0 comments on commit 2b7e730

Please sign in to comment.