Skip to content

Instantly share code, notes, and snippets.

@iMichaelOwolabi
Created September 30, 2022 20:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iMichaelOwolabi/4da4997767773f314914dbdefbd5c4db to your computer and use it in GitHub Desktop.
Save iMichaelOwolabi/4da4997767773f314914dbdefbd5c4db to your computer and use it in GitHub Desktop.
Email transporter code for passwordless auth app
import nodemailer from 'nodemailer';
import { config } from 'dotenv';
config()
export const emailSender = async (to, firstName, token) => {
const trasporter = await nodemailer.createTransport({
host: process.env.MAILGUN_SMTP_HOSTNAME,
port: process.env.SMTP_PORT,
secure: false,
auth: {
user: process.env.MAILGUN_SMTP_USERNAME,
pass: process.env.MAILGUN_SMTP_PASSWORD,
},
});
await trasporter.sendMail({
from: `"Passwordless Auth" <nopassword@auth.com>`, // sender address
to: `${to}`,
subject: "Welcome to Passwordless Authentication",
html: `<p><b>Hey ${firstName},</b></p> <p>You are welcome to the world of passwordless authentication. Kindly click the link below to login: </p>
<a href='http://localhost:${process.env.PORT}/api/v1/auth/verify/${token}'>http://localhost:${process.env.PORT}/authenticate/${token}</a>.
`,
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment