feat: ContactUs Form
This commit is contained in:
parent
88c7d2e2c1
commit
488177b640
9 changed files with 844 additions and 38672 deletions
21
app/api/routes/mailTransporter.ts
Normal file
21
app/api/routes/mailTransporter.ts
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
const nodemailer = require("nodemailer")
|
||||
|
||||
export interface MailOptions {
|
||||
from: string
|
||||
to: string
|
||||
}
|
||||
|
||||
export const transporter = nodemailer.createTransport({
|
||||
host: "smtp.zoho.com",
|
||||
port: 465,
|
||||
secure: true,
|
||||
auth: {
|
||||
user: "keshawa.vizolelabs.com",
|
||||
pass: process.env.ZOHO_PASS,
|
||||
},
|
||||
})
|
||||
|
||||
export const mailOptions: MailOptions = {
|
||||
from: "Keshawa Anuhas <keshawa.vizolelabs.com>",
|
||||
to: "Keshawa Anuhas <keshawa.vizolelabs.com>",
|
||||
}
|
||||
19
app/api/routes/route.ts
Normal file
19
app/api/routes/route.ts
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
import { mailOptions, transporter } from "./mailTransporter"
|
||||
|
||||
import { NextResponse } from "next/server"
|
||||
|
||||
export async function post(req: any) {
|
||||
const data = await req.json()
|
||||
|
||||
try {
|
||||
await transporter.sendMail({
|
||||
...mailOptions,
|
||||
subject: data.subject,
|
||||
text: `Email: ${data.email}\n\n${data.message}`,
|
||||
})
|
||||
return NextResponse.json({ success: true })
|
||||
} catch (error: any) {
|
||||
console.error(error)
|
||||
return NextResponse.json({ error: error.message }, { status: error.status })
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue