-
-
Notifications
You must be signed in to change notification settings - Fork 63
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
1 parent
768afc3
commit fff446e
Showing
9 changed files
with
871 additions
and
113 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,17 +6,14 @@ import { hash } from "bcryptjs"; | |
import { NextRequest, NextResponse } from "next/server"; | ||
import { z } from "zod"; | ||
|
||
import { Resend } from 'resend'; | ||
import otpEmailTemplate from "@/lib/templates/otp-template"; | ||
import mailer from "@/lib/mailer"; | ||
|
||
|
||
|
||
const resendAPI = process.env.RESEND_API_KEY; | ||
// `[email protected]` email is for development only | ||
const senderEmail = process.env.SENDER_EMAIL || "[email protected]"; | ||
|
||
// `[email protected]` email is for development only | ||
const resendEmail = process.env.RESENDL_EMAIL || "[email protected]"; | ||
|
||
const resend = new Resend(resendAPI); | ||
|
||
|
||
export async function POST(req: NextRequest) { | ||
|
@@ -69,17 +66,13 @@ export async function POST(req: NextRequest) { | |
}); | ||
|
||
|
||
|
||
const res = await resend.emails.send({ | ||
from: `Uttarakhand Culture <${resendEmail}>`, | ||
await mailer.sendMail({ | ||
from: `Uttarakhand Culture <${senderEmail}>`, | ||
to: [email], | ||
subject: 'Verify you email with OTP', | ||
html: otpEmailTemplate(name, otp), | ||
}); | ||
}) | ||
|
||
if (res.error) { | ||
console.log(res.error) | ||
} | ||
|
||
|
||
|
||
|
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 |
---|---|---|
|
@@ -4,16 +4,14 @@ import { otps } from "@/lib/schema"; | |
import { NextRequest, NextResponse } from "next/server"; | ||
import { z } from "zod"; | ||
|
||
import { Resend } from 'resend'; | ||
import otpEmailTemplate from "@/lib/templates/otp-template"; | ||
import { auth } from "@/auth"; | ||
import mailer from "@/lib/mailer"; | ||
|
||
|
||
|
||
const resendAPI = process.env.RESEND_API_KEY; | ||
// `[email protected]` email is for development only | ||
const resendEmail = process.env.RESENDL_EMAIL || "[email protected]"; | ||
const resend = new Resend(resendAPI); | ||
// `[email protected]` email is for development only | ||
const senderEmail = process.env.SENDER_EMAIL || "[email protected]"; | ||
|
||
|
||
export async function POST(req: NextRequest) { | ||
|
@@ -60,16 +58,14 @@ export async function POST(req: NextRequest) { | |
|
||
|
||
|
||
const res = await resend.emails.send({ | ||
from: `Uttarakhand Culture <${resendEmail}>`, | ||
|
||
await mailer.sendMail({ | ||
from: `Uttarakhand Culture <${senderEmail}>`, | ||
to: [userWithEmail.email!], | ||
subject: 'Verify you email with OTP', | ||
html: otpEmailTemplate(userWithEmail.name!, otp), | ||
}); | ||
}) | ||
|
||
if (res.error) { | ||
console.log(res.error) | ||
} | ||
|
||
|
||
|
||
|
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import nodemailer from 'nodemailer'; | ||
|
||
|
||
|
||
const mailer = nodemailer.createTransport({ | ||
host: process.env.MAIL_SERVER_HOST as string, | ||
port: 587, | ||
secure: false, // Use `true` for port 465, `false` for all other ports | ||
auth: { | ||
user: process.env.MAIL_SERVER_USER, | ||
pass: process.env.MAIL_SERVER_PASS, | ||
} | ||
}); | ||
|
||
export default mailer; |
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