next email library
Hello im working on password recovery by email feature in next js. which mailing lib/service u suggest
23 Replies
nodemailer, it's fairly simple
you could even use React Email with it
Theo made a video about React Email recently
https://www.youtube.com/watch?v=Xa1WaSPu5K8&t=166s
https://react.email/docs/integrations/nodemailer
they give more integrations on their website, you can use the one you'd like
https://react.email/docs/integrations/overview
thanks i'll use react email with nodemailer integration
or should i use resend instead ?
I used nodemailer in my project, works absolute fine for the pass reset purposes, but you could try both and use the one you are more comfortable with
Resend
Build, test, and send transactional emails at scale.
thanks guys
if u dont mind i want to send that verification token through that email how can i generate it and make it match both on server and client sides ?
I used jwt to encode user's id with custom secret phrase that I match on the server
jwt js lib has encode and decode methods for it, very handy
you can also set expiration date in it for auto rejection if too much time passed
const token = jwt.sign({ id: user.id }, process.env.JWT_SECRET!, {
expiresIn: "15m",
});
jwt works for that.
either jwt or storing a secret token in the database.
and you can send the token as a query parameter on the link, like https://your-app.com/forgotPass?token={YOUR_TOKEN_HERE}
then you send the token form the query as part of user's request for the password change, and validate it on the server
what about the
process.env.JWT_SECRET!
should imake it with openssl?yeah, that's what I did
thanks budd
what is the lib for jwt ?
'openssl rand -base64 32' - it's the terminal command for a secret
jsonwebtoken
https://www.npmjs.com/package/jsonwebtoken
damn u're a life saver thanks mate
https://jwt.io/libraries - you can choose another
there's one called Jose
but i haven't used it
i think i normally use jose when i do jwt stuffs