For Developers By Developers

You can integrate Mailazy in minutes with your platform. Build and monitor your email solution on a trusted foundation with technical and strategic support when you need it the most.

Trusted by 120+ partners and delivering over 650 Million emails/month

Configure OTP emails with SMTP for Nextjs

OTP emails is an important component of any email communication strategy. In order to ensure delivery of OTP emails to your customers, reply on a trusted cloud-based email provider like Mailazy as a partner in your growth journey.

Prerequisites

You need to complete these given prerequisites, you can skip the step if you have already completed.

  1. Sign up for a Mailazy account.

  2. Complete Domain Authentication.

  3. Generate the Mailazy Access Key

Integrate Mailazy with NextJs

  1. Create Next App
npx create-next-app
  1. Add the Form
< form className={styles.main} > < formGroup className={styles.inputGroup} > < label htmlFor='name'>Name < input type='text' onChange={(e)=>{setName(e.target.value)}} name='name' className={styles.inputField} /> < formGroup className={styles.inputGroup} > < label htmlFor='email'>Email < input type='text' onChange={(e)=>{setEmail(e.target.value)}} name='email’' className={styles.inputField} /> < formGroup className={styles.inputGroup} > < label htmlFor='message'>Message < input type='text' onChange={(e)=>{setMessage(e.target.value)}} name='message' className={styles.inputField} /> < input type='submit' onChange={(e)=>{setSubmitted(e.target.value)}}/>
  1. Added StyleSheet
.inputGroup {
  height: 50%;
  width: 200%;
  display: flex;
  flex-direction: column;
  margin: 10px 0;
}
.inputLabel {
  text-align: left;
}
.inputField {
  height: 30px;
}
  1. Set up Nodemailer
export default function (req, res) {
require('dotenv').config()
let nodemailer = require('nodemailer')
const transporter = nodemailer.createTransport({
  port: 587,
  host: "smtp.mailazy.com",
  auth: {
    user: process.env.mailazy_apikey,
    pass: process.env.mailazy_secret,
  },
  secure: false,
})

const mailData = {
  from: 'demo email',
  to: 'your email',
  subject: `Message From ${req.body.name}`,
  text: req.body.message + " | Sent from: " + req.body.email,
  html: `
${req.body.message}

Sent from: ${req.body.email}

` } transporter.sendMail(mailData, function (err, info) { if(err) console.log(err) else console.log(info) }) res.status(200) }

Send transactional emails with Mailazy

Mailazy email delivery platform is powered by AI and uses the global infrastructure so that you can scale effortlessly. Mailazy is the trusted transactional email provider for hundreds of businesses and we are growing every day. We are known for being the most reliable and trusted senders on the internet.

Ready to get started?

Get started — it's free