Skip to content

Commit

Permalink
added email template for contact form
Browse files Browse the repository at this point in the history
  • Loading branch information
carvalholuigi25 committed Nov 2, 2023
1 parent 48bf0ad commit f07dead
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/app/[locale]/templates/email.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/app/[locale]/templates/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './email';
5 changes: 3 additions & 2 deletions src/app/api/sendemail/route.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { NextResponse } from "next/server";
import { sendMailUtil } from '../../[locale]/utils/sendmailUtils';
import { EmailTemplate } from '../../[locale]/templates';

export async function POST(req: any) {
const body = await req.json();
const dataobj = {
to: process.env.EMAIL_USER,
from: body.email,
from: `"${body.name}" <${body.email}>`,
subject: body.subject,
text: `${body.message}\r\n Sent by ${body.email} (${body.name})`,
html: `<!doctype html><html><head><title>Hello</title></head><body><b>${body.message}</b><p>Sent by: ${body.email} (${body.name})</p></body></html>`
html: EmailTemplate(body)
};

console.log(dataobj);
Expand Down

0 comments on commit f07dead

Please sign in to comment.