Visit the Website
How to make a stunning website in under three days.
Code Snippets
> Contact Form Cloud Function
1export default async function handler(request: NextApiRequest, response: NextApiResponse) {
2 const transporter = createTransport({
3 host: 'smtp.gmail.com',
4 port: 465,
5 secure: true, // use TLS
6 auth: {
7 user: 'essayswithori@gmail.com',
8 pass: process.env.SMTP_PASSWORD,
9 },
10 });
11 const info = await transporter.sendMail({
12 from: 'Essays with Ori (essayswithori@gmail.com)',
13 to:
14 process.env.NODE_ENV == 'development' ? process.env.DEV_EMAIL : process.env.PROD_EMAIL,
15 subject: `Message from ${request.body.sender.firstname} ${request.body.sender.lastname} (${request.body.sender.email}): ${request.body.subject}`, // subject line
16 text: request.body.message, // plain text body
17 });
18 response.status(200).json({
19 status: info.accepted
20 ? 'success'
21 : info.pending
22 ? 'pending'
23 : info.rejected
24 ? 'rejected'
25 : 'unknown',
26 });
27}