Merge version_3 into main #6
@@ -1,13 +1,30 @@
|
||||
import { NextRequest, NextResponse } from 'next/server';
|
||||
import nodemailer from 'nodemailer';
|
||||
|
||||
const transporter = nodemailer.createTransport({
|
||||
service: 'gmail',
|
||||
auth: {
|
||||
user: process.env.HOTEL_EMAIL,
|
||||
pass: process.env.HOTEL_EMAIL_PASSWORD,
|
||||
const transporter = {
|
||||
sendMail: async (mailOptions: { from?: string; to: string; subject: string; html: string }) => {
|
||||
try {
|
||||
const response = await fetch('https://api.resend.com/emails', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': `Bearer ${process.env.RESEND_API_KEY}`,
|
||||
},
|
||||
body: JSON.stringify({
|
||||
from: mailOptions.from || process.env.HOTEL_EMAIL,
|
||||
to: mailOptions.to,
|
||||
subject: mailOptions.subject,
|
||||
html: mailOptions.html,
|
||||
}),
|
||||
});
|
||||
if (!response.ok) {
|
||||
throw new Error('Failed to send email');
|
||||
}
|
||||
return { success: true };
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
export async function POST(request: NextRequest) {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user