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 Verification emails with SMTP for Hasura
Verification emails is an important component of any email communication strategy. In order to ensure delivery of Verification 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 Hasura
Write the webhook
const nodemailer = require("nodemailer");
const transporter = nodemailer.createTransport(
"smtp://" +
process.env.SMTP_LOGIN +
":" +
process.env.SMTP_PASSWORD +
"@" +
process.env.SMTP_HOST
);
const fs = require("fs");
const path = require("path");
const express = require("express");
const bodyParser = require("body-parser");
const app = express();
app.set("port", process.env.PORT || 3000);
app.use("/", express.static(path.join(__dirname, "public")));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(function (req, res, next) {
res.setHeader("Access-Control-Allow-Origin", "*");
res.setHeader("Cache-Control", "no-cache");
next();
});
app.post("/send-email", function (req, res) {
const name = req.body.event.data.new.name;
// setup e-mail data
const mailOptions = {
from: process.env.SENDER_ADDRESS, // sender address
to: process.env.RECEIVER_ADDRESS, // list of receivers
subject: "A new user has registered", // Subject line
text:
"Hi, This is to notify that a new user has registered under the name of " +
name, // plaintext body
html:
"" +
"Hi, This is to notify that a new user has registered under the name of " +
name +
"
", // html body
};
// send mail with defined transport object
transporter.sendMail(mailOptions, function (error, info) {
if (error) {
return console.log(error);
}
console.log("Message sent: " + info.response);
res.json({ success: true });
});
});
app.listen(app.get("port"), function () {
console.log("Server started on: " + app.get("port"));
});
Set the environment variables
After remixing to your own project on Glitch, modify the .env file to enter the
- SMTP_LOGIN : mailazy_apikey
- SMTP_PASSWORD : mailazy_secret
- SMTP_HOST : smtp.mailazy.com
- SENDER_ADDRESS : sender email address
- RECEIVER_ADDRESS : receiver email address
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