The Best Price for IPv4/IPv6 Lease – Any RIR & Any Geo-LocationOrder Now
Hostperl

Setup MailWatch Email Monitoring on Ubuntu VPS: Real-Time Dashboard

By Raman Kumar

Share:

Updated on Jun 6, 2026

Setup MailWatch Email Monitoring on Ubuntu VPS: Real-Time Dashboard

Understanding MailWatch for Production Email Monitoring

Email server performance can make or break your business operations. MailWatch provides real-time monitoring for Postfix mail servers. You get visibility into message flow, queue status, and delivery performance that basic log files can't match.

This dashboard tracks every aspect of your mail server's activity. You'll see message counts, delivery times, bounce rates, and spam statistics in one interface. For hosting providers and system administrators managing multiple domains, this visibility is essential for maintaining service quality.

When customers report email issues, you need immediate answers. MailWatch eliminates the guesswork by showing exactly what's happening with your mail flow in real time.

Prerequisites and System Requirements

Before installing MailWatch, verify your Ubuntu VPS meets these requirements:

  • Ubuntu 22.04 LTS or newer with root access
  • Postfix mail server already configured and running
  • MySQL or MariaDB database server
  • Apache or Nginx web server with PHP support
  • Minimum 2GB RAM for stable operation
  • At least 10GB free disk space for log storage

Check your current Postfix status:

systemctl status postfix
postconf mail_version

Your mail server should be handling real traffic for meaningful monitoring data. If you're running a Hostperl VPS with email services, ensure your DNS records and mail routing work correctly first.

Install Required Dependencies

Update your system packages and install the necessary components:

apt update && apt upgrade -y
apt install -y apache2 mysql-server php php-mysql php-gd \
    php-mbstring php-xml unzip wget curl

Enable and start the required services:

systemctl enable apache2 mysql
systemctl start apache2 mysql

Secure your MySQL installation:

mysql_secure_installation

Follow the prompts to set a root password, remove anonymous users, and disable remote root login. These security steps protect your mail monitoring data from unauthorized access.

Configure Database for MailWatch

Create a dedicated database and user for MailWatch. Log into MySQL as root:

mysql -u root -p

Execute these SQL commands to set up the database structure:

CREATE DATABASE mailwatch CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'mailwatch'@'localhost' IDENTIFIED BY 'secure_password_here';
GRANT ALL PRIVILEGES ON mailwatch.* TO 'mailwatch'@'localhost';
FLUSH PRIVILEGES;
EXIT;

Replace 'secure_password_here' with a strong password containing uppercase letters, numbers, and symbols. Store these credentials safely—you'll need them during configuration.

Test the database connection:

mysql -u mailwatch -p mailwatch

Download and Setup MailWatch Email Monitoring on Ubuntu VPS

Download the latest MailWatch release from the official repository:

cd /tmp
wget https://github.com/mailwatch/1.2.0/archive/master.zip
unzip master.zip
mv mailwatch-1.2.0-master /var/www/html/mailwatch

Set appropriate ownership and permissions:

chown -R www-data:www-data /var/www/html/mailwatch
chmod -R 755 /var/www/html/mailwatch

Import the database schema:

mysql -u mailwatch -p mailwatch < /var/www/html/mailwatch/create.sql

This creates all necessary tables for storing mail statistics, user accounts, and configuration settings. The schema includes indexes optimized for regular MailWatch queries.

Configure MailWatch Application Settings

Copy the sample configuration file and customize it:

cd /var/www/html/mailwatch
cp conf.php.example conf.php
nano conf.php

Edit these essential configuration parameters:

define('DB_TYPE', 'mysql');
define('DB_USER', 'mailwatch');
define('DB_PASS', 'secure_password_here');
define('DB_HOST', 'localhost');
define('DB_NAME', 'mailwatch');

// Set your timezone
define('TIME_ZONE', 'Pacific/Auckland');

// Configure your mail server details
define('MAILQUEUE', '/var/spool/postfix/deferred');
define('SENDMAIL', '/usr/sbin/sendmail');

For customers using managed VPS hosting, these paths typically remain standard across Ubuntu installations. Verify your specific Postfix queue location if you've customized your mail server configuration.

Setup Postfix Integration and Log Parsing

MailWatch needs to parse Postfix logs to gather mail statistics. Configure the log parsing script:

cd /var/www/html/mailwatch/tools/Postfix_relay
cp mailwatch_relay.php /usr/local/bin/
chmod +x /usr/local/bin/mailwatch_relay.php

Edit your Postfix main configuration to enable MailWatch logging:

nano /etc/postfix/main.cf

Add or modify these settings:

# Enable detailed logging for MailWatch
maillog_file = /var/log/postfix.log

# Configure content filter for MailWatch
content_filter = mailwatch:[127.0.0.1]:10025

Configure the MailWatch content filter in master.cf:

nano /etc/postfix/master.cf

Add this service definition:

mailwatch unix - n n - - pipe
  flags=Rq user=mailwatch argv=/usr/local/bin/mailwatch_relay.php
  ${sender} ${size} ${recipient}

Restart Postfix to apply these changes:

systemctl restart postfix

Configure Web Server Access

Create an Apache virtual host specifically for MailWatch:

nano /etc/apache2/sites-available/mailwatch.conf

Configure the virtual host with appropriate security settings:


    ServerName mailwatch.yourdomain.com
    DocumentRoot /var/www/html/mailwatch
    
    
        Options -Indexes
        AllowOverride All
        Require all granted
        
        # Security headers
        Header always set X-Content-Type-Options nosniff
        Header always set X-Frame-Options DENY
        Header always set X-XSS-Protection "1; mode=block"
    
    
    ErrorLog ${APACHE_LOG_DIR}/mailwatch_error.log
    CustomLog ${APACHE_LOG_DIR}/mailwatch_access.log combined

Enable the site and required Apache modules:

a2ensite mailwatch
a2enmod rewrite headers
systemctl reload apache2

For production deployments, configure SSL immediately. Never run monitoring dashboards over unencrypted connections, especially when handling email metadata.

Create Administrative User Account

Set up the initial administrator account through the web interface. Navigate to your MailWatch installation:

http://your-server-ip/mailwatch/

The first-time setup wizard guides you through creating the admin account. Use a strong password and enable two-factor authentication if available.

Alternatively, create the admin user directly via database:

mysql -u mailwatch -p mailwatch
INSERT INTO users (username, password, type, active) 
VALUES ('admin', MD5('your_secure_password'), 'A', 'Y');

The 'A' type designates administrator privileges. This allows full access to all monitoring features and configuration settings.

Configure Real-Time Data Collection

Set up automated log parsing to keep your dashboard current. Create a cron job for regular data updates:

crontab -e

Add these scheduled tasks:

# Parse mail logs every 5 minutes
*/5 * * * * /usr/local/bin/mailwatch_relay.php > /dev/null 2>&1

# Clean old records daily at 2 AM
0 2 * * * /var/www/html/mailwatch/tools/cleanup.php > /dev/null 2>&1

# Generate daily reports
0 6 * * * /var/www/html/mailwatch/tools/daily_report.php > /dev/null 2>&1

These automated tasks ensure your monitoring data stays current without manual intervention. The cleanup script prevents your database from growing indefinitely. It removes old statistics according to your retention policy.

Testing and Verification

Send test emails through your server to verify MailWatch captures the activity correctly:

echo "Test message from MailWatch setup" | mail -s "Test Subject" test@yourdomain.com

Check the MailWatch dashboard for the test message appearance. You should see real-time updates showing message processing, delivery status, and any errors encountered.

Monitor the application logs for any configuration issues:

tail -f /var/log/apache2/mailwatch_error.log
tail -f /var/log/postfix.log

Successful integration shows message flow data populating within minutes of email activity. If data doesn't appear, verify your Postfix logging configuration and database connectivity.

Ready to implement professional email monitoring for your hosting environment? Our Hostperl VPS plans provide the ideal platform for running MailWatch with dedicated resources and reliable performance.

Frequently Asked Questions

How much disk space does MailWatch require for log storage?

Plan for approximately 100MB per million processed messages. High-volume mail servers should allocate at least 10GB initially. Use automated cleanup policies to manage growth over time.

Can MailWatch monitor multiple Postfix servers simultaneously?

Yes, configure multiple server instances by modifying the relay configuration. This accepts log data from remote Postfix installations. Ensure secure communication channels between servers.

What security measures should I implement for MailWatch?

Enable SSL/TLS encryption, implement strong authentication, restrict access by IP address, and regularly update the application. Never expose MailWatch directly to the internet without proper security controls.

How do I troubleshoot missing mail statistics?

Check Postfix logging configuration, verify database connectivity, and ensure the parsing scripts have appropriate permissions. Review error logs for specific configuration issues.

Can I integrate MailWatch with external monitoring systems?

MailWatch provides API endpoints for integrating with monitoring platforms like Nagios, Zabbix, or Prometheus. Configure custom alerts based on mail queue sizes, delivery rates, or error thresholds.