Mailtrain is an open-source, self-hosted email list management platform built on Node.js. It handles subscriber lists, campaign scheduling, and SMTP delivery — all on your own infrastructure. That self-hosted control means you own the uptime: if your Mailtrain instance goes down during a campaign send, emails queue silently, subscribers experience delays, and you may not know until campaign reports show a delivery cliff. Vigilmon monitors each layer of your Mailtrain stack so you catch failures before they affect campaigns.
What You'll Set Up
- HTTP uptime monitoring for the Mailtrain web UI
- Health endpoint to verify application and database readiness
- SMTP queue heartbeat to confirm delivery workers are running
- Database and Redis connectivity checks
- SSL certificate expiry alerts
Prerequisites
- Mailtrain v2 or later deployed on a Linux VPS or Docker
- Node.js, MySQL/MariaDB (or MongoDB for v2), and an SMTP relay configured
- A free Vigilmon account
Step 1: Monitor the Mailtrain Web Interface
Mailtrain's web UI is the entry point for everything — list management, campaign creation, and reports. If it's down, operators are blind.
- Log in to vigilmon.online and click Add Monitor.
- Set Type to
HTTP / HTTPS. - Enter your Mailtrain URL:
https://mail.yourdomain.com. - Set Check interval to
1 minute. - Set Expected HTTP status to
200. - Add a keyword check for
"Mailtrain"or your organization name — catches cases where nginx returns 200 but serves an error page. - Click Save.
Step 2: Add a Health Check Endpoint to Mailtrain
Mailtrain doesn't ship with a health endpoint by default. Add one using Mailtrain's plugin system or a custom Express route in a local fork.
If you're running Mailtrain behind nginx and have access to the source, add a lightweight health route:
// In Mailtrain's Express app setup (routes/health.js)
const express = require('express');
const router = express.Router();
const db = require('../lib/db');
router.get('/', async (req, res) => {
const status = { app: 'ok' };
try {
await db.query('SELECT 1');
status.database = 'ok';
} catch (e) {
status.database = e.message;
}
const code = Object.values(status).every(v => v === 'ok') ? 200 : 503;
res.status(code).json(status);
});
module.exports = router;
Register it in the main app file:
app.use('/health', require('./routes/health'));
Then update your Vigilmon monitor to probe https://mail.yourdomain.com/health. A 503 response tells you whether it's the application or the database that's failing.
Alternatively, if you can't modify Mailtrain's source, use a TCP monitor (Step 3) to verify the port is listening.
Step 3: Add a TCP Port Monitor
Even without a health endpoint, a TCP check verifies that Mailtrain's Node.js process is alive and accepting connections.
- In Vigilmon, click Add Monitor → TCP Port.
- Enter your server's IP or hostname.
- Enter Mailtrain's port (
3000by default, or443if behind nginx with SSL termination). - Set Check interval to
1 minute. - Click Save.
Pair this with the HTTP monitor — if HTTP fails but TCP succeeds, the application is running but returning errors. If both fail, the process has crashed.
Step 4: Monitor SMTP Queue Workers with a Heartbeat
Mailtrain sends emails through SMTP zones configured in the admin panel. When a campaign runs, a sending worker picks up messages and delivers them via your SMTP relay. If the worker crashes mid-campaign, the queue stalls.
Add a heartbeat cron job that pings Vigilmon after each successful queue flush:
- In Vigilmon, click Add Monitor → Cron Heartbeat.
- Set the expected ping interval to match your sending frequency (e.g.,
10 minutesfor a high-volume deployment). - Copy the heartbeat URL.
- Set the
VIGILMON_HEARTBEAT_URLenvironment variable on your Mailtrain server.
Add a cron script on your server that verifies the queue depth and pings if it's draining:
#!/bin/bash
# /usr/local/bin/mailtrain-queue-check.sh
QUEUE_SIZE=$(mysql -u mailtrain -p"$DB_PASS" mailtrain -sNe \
"SELECT COUNT(*) FROM sent_messages WHERE status='queued' AND created < NOW() - INTERVAL 10 MINUTE;")
# If queue is not growing stale, signal Vigilmon
if [ "$QUEUE_SIZE" -lt 1000 ]; then
curl -s "$VIGILMON_HEARTBEAT_URL"
fi
Schedule it with cron:
*/10 * * * * /usr/local/bin/mailtrain-queue-check.sh
If the sending zone workers crash or the queue stops draining, the heartbeat stops and Vigilmon alerts.
Step 5: Monitor the Database
Mailtrain stores subscribers, lists, campaigns, and send logs in MySQL/MariaDB. A database failure stops all operations.
Use a TCP monitor to verify the database port:
- Add a TCP Port monitor for your database server.
- Enter the MySQL port (
3306). - Set Check interval to
1 minute.
For external database servers (RDS, managed MySQL), add the database host and port. If your database is on the same host as Mailtrain, the application health check in Step 2 already covers this via the SELECT 1 query.
Step 6: SSL Certificate Alerts
Mailtrain is typically served behind nginx with Let's Encrypt certificates. Expired certificates break the web UI and any API integrations that call your Mailtrain instance.
- Open the HTTP / HTTPS monitor for your Mailtrain URL.
- Enable Monitor SSL certificate.
- Set Alert when certificate expires in less than
21 days.
Check your nginx config to confirm which domains are covered:
grep -r "server_name" /etc/nginx/sites-enabled/
Add a separate SSL monitor for each domain served by Mailtrain.
Step 7: Configure Alert Channels
- Go to Alert Channels in Vigilmon and add Slack, email, or PagerDuty.
- Route queue heartbeat alerts to your operations team — a missed heartbeat during a campaign send needs immediate attention.
- Set Consecutive failures before alert to
2on the UI monitor to avoid false positives from transient nginx reloads. - Add a maintenance window in Vigilmon before planned deployments:
curl -X POST https://vigilmon.online/api/maintenance \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{"monitor_id": "your-monitor-id", "duration_minutes": 15}'
Summary
| Monitor | Target | What It Catches |
|---|---|---|
| Web UI | https://mail.yourdomain.com | UI down, nginx proxy failure |
| Health endpoint | /health | Application or database error |
| TCP port | :3000 or :443 | Node.js process crash |
| SMTP queue heartbeat | Heartbeat URL | Sending worker crash, queue stall |
| Database TCP | :3306 | MySQL unreachable |
| SSL certificate | Mailtrain domain | Let's Encrypt renewal failure |
Self-hosted Mailtrain gives you full control over your email marketing infrastructure — but also full responsibility for its uptime. Vigilmon covers the web layer, application layer, database, and SMTP queue, ensuring you know about failures within minutes rather than discovering them through a campaign's bounce report.