diff --git a/src/app/[locale]/templates/email.js b/src/app/[locale]/templates/email.js
new file mode 100644
index 0000000..0364b37
--- /dev/null
+++ b/src/app/[locale]/templates/email.js
@@ -0,0 +1,5 @@
+// minify html code by using this website: https://codebeautify.org/minify-html
+
+const EmailTemplate = (embody) => `
EmailThank you for contact us! Here's the message:
Date: ${new Date().toUTCString()}
To: ${process.env.EMAIL_USER}
From: ${embody.email}
Name: ${embody.name}
Subject: ${embody.subject}
Body: ${embody.message}
`;
+
+export { EmailTemplate }
\ No newline at end of file
diff --git a/src/app/[locale]/templates/index.js b/src/app/[locale]/templates/index.js
new file mode 100644
index 0000000..b712dbc
--- /dev/null
+++ b/src/app/[locale]/templates/index.js
@@ -0,0 +1 @@
+export * from './email';
\ No newline at end of file
diff --git a/src/app/api/sendemail/route.ts b/src/app/api/sendemail/route.ts
index 5bb89f1..3d4b717 100644
--- a/src/app/api/sendemail/route.ts
+++ b/src/app/api/sendemail/route.ts
@@ -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: `Hello${body.message}Sent by: ${body.email} (${body.name})
`
+ html: EmailTemplate(body)
};
console.log(dataobj);