-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
71 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { NextResponse } from 'next/server' | ||
import Sendgrid from '@sendgrid/mail' | ||
|
||
export async function POST(request: Request) { | ||
try { | ||
const { email, code } = await request.json() | ||
|
||
if (!email || !code) { | ||
return NextResponse.json( | ||
{ error: 'Email and code are required' }, | ||
{ status: 400 } | ||
) | ||
} | ||
|
||
Sendgrid.setApiKey(process.env.SENDGRID_API_KEY as string) | ||
|
||
const msg = { | ||
to: email, | ||
from: '[email protected]', // Replace with your verified sender | ||
templateId: 'd-070a0738fac147eb878f87b86eed664c', | ||
dynamicTemplateData: { | ||
VCODE: code | ||
} | ||
} | ||
|
||
await Sendgrid.send(msg) | ||
|
||
return NextResponse.json({ success: true }) | ||
} catch (error) { | ||
console.error('Error sending email:', error) | ||
return NextResponse.json( | ||
{ error: 'Failed to send verification email' }, | ||
{ status: 500 } | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters