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.
Configure Transactional emails with SMTP for Nextjs
Transactional emails is an important component of any email communication strategy. In order to ensure delivery of Transactional 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.
Sign up for a Mailazy account.
Complete Domain Authentication.
Generate the Mailazy Access Key
Integrate Mailazy with NextJs
Create Next App
npx create-next-app
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)}}/>
Added StyleSheet
.inputGroup {
height: 50%;
width: 200%;
display: flex;
flex-direction: column;
margin: 10px 0;
}
.inputLabel {
text-align: left;
}
.inputField {
height: 30px;
}
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 Emails with Mailazy
Mailazy is a simple email service to use, yet it provides so many benefits. Mailazy is the only simple transactional email service you’ll need. And the forever free plan lets you test drive it., Mailazy's team is well-equipped to help you quickly resolve your queries and issues. Try us for free today!
Signup for Free Developer DocumentationReady to get started?
For High-Volume custom requirements send us an email and we will come up with a detailed quote within 24 hours.
Contact Us