feat: implement email sending functionality with nodemailer; add contact form handling and success/error notifications
This commit is contained in:
17
app/utils/send-email.tsx
Normal file
17
app/utils/send-email.tsx
Normal file
@@ -0,0 +1,17 @@
|
||||
import {FormData} from "@/app/components/Contact";
|
||||
|
||||
export function sendEmail(data: FormData): Promise<{ success: boolean, message: string }> {
|
||||
const apiEndpoint = '/api/email';
|
||||
|
||||
return fetch(apiEndpoint, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(data),
|
||||
})
|
||||
.then((res) => res.json())
|
||||
.then((response) => {
|
||||
return {success: true, message: response.message};
|
||||
})
|
||||
.catch((err) => {
|
||||
return {success: false, message: err.message};
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user