Schedule an Email for Later
This is a guide on how you can schedule an email using Loophook.

Set up the server

The server setup here is simple. A POST endpoint is defined which is listens to request
The sendEmail function sends a test email using nodemailer.
const express = require("express");
const nodemailer = require("nodemailer");
async function sendEmail() {
// Generate test SMTP service account from ethereal.email
let testAccount = await nodemailer.createTestAccount();
let transporter = nodemailer.createTransport({
host: "smtp.ethereal.email",
port: 587,
secure: false, // true for 465, false for other ports
auth: {
user: testAccount.user, // generated ethereal user
pass: testAccount.pass, // generated ethereal password
let info = await transporter.sendMail({
from: '"Fred Foo πŸ‘»" <[email protected]>', // sender address
to: "[email protected], [email protected]", // list of receivers
subject: "Hello βœ”", // Subject line
text: "Hello world?", // plain text body
html: "<b>Hello world?</b>", // html body
console.log("Message sent: %s", info.messageId);
// Preview URL: https://ethereal.email/message
console.log("Preview URL: %s", nodemailer.getTestMessageUrl(info));
const app = express();
app.post("/send-email", async (req, res) => {
await sendEmail();
return res.sendStatus(200);
app.listen(5000, () => console.log("Server listening on port 5000"));

Download and install ngrok

To allow sending request to the server on localhost, a tunneling service like ngrok is required. You can download it from https://ngrok.com/download. Once done, simply follow the steps and start a tunnel on port 5000.

Creating a Task

Go to the Loophook dashboard and add your ngrok endpoint.
Create a request to /send-email.
Define a schedule, here it's a cron that runs every minute.
Run the task.
Running the task should print something similar to the following in the console.
Copy link
On this page
Set up the server
Download and install ngrok
Creating a Task