← All guides

Monitor Mail Queue & SMTP Status: mailq and postqueue

Updated:

Monitor Mail Queue & SMTP Status: mailq and postqueue

Monitor email queue and SMTP status to track email delivery, detect queue issues, and ensure reliable email service. This guide shows you how to monitor email queue and set up automated monitoring.

For comprehensive email monitoring, see Email Delivery Monitoring. For troubleshooting email issues, see Email Delivery Failures.

Why Monitoring Email Queue Matters

Email queue monitoring helps detect email delivery issues, prevent queue buildup, and ensure reliable email service. Large email queues can indicate delivery problems or server issues.

Method 1: Check Email Queue Status

Check Postfix Queue

# Check email queue length
mailq | wc -l

# View emails in queue
mailq

# Check queue details
postqueue -p

# Count emails in queue
postqueue -p | grep -c "^[A-F0-9]"

Check Sendmail Queue

# Check sendmail queue
mailq

# View queue details
sendmail -bp

# Count emails in queue
mailq | grep -c "^[A-F0-9]"

Monitor Queue Size Over Time

# Track queue size
while true; do
  COUNT=$(mailq | wc -l)
  echo "$(date): $COUNT emails in queue"
  sleep 60
done

Method 2: Check SMTP Server Status

Test SMTP Connection

# Test SMTP server connection
telnet smtp.example.com 25

# Test SMTP with timeout
timeout 5 telnet smtp.example.com 25

# Check SMTP server response
echo "QUIT" | telnet smtp.example.com 25

Check SMTP Server Logs

# View SMTP logs (Postfix)
sudo tail -f /var/log/mail.log | grep smtp

# View SMTP errors
sudo grep -i error /var/log/mail.log | tail -20

# Count SMTP errors
sudo grep -i error /var/log/mail.log | wc -l

Method 3: Automated Email Queue Monitoring with Zuzia.app

Manual checks work while you are looking. To keep running them without you, Zuzia uses its agent and scheduled tasks.

How it works in Zuzia

  • Install the Zuzia agent on the server with one command. CPU, RAM, disk, load and network metrics start reporting on their own, with alerts on a threshold, on drift from the server's normal, or on a disk fill-up forecast.
  • Save the commands from this guide as a scheduled task and choose how often it runs, from every minute to once a year. The agent runs it on every host you pick.
  • If a command fails, you get an alert right away by email, Slack, Discord, push (through your Pushover account) or SMS (through your Vonage account).
  • The output of every run is kept, so you can look back at what changed. On paid plans, AI can read the output and alert you only when it spots a problem.

Setting it up

  1. Add the server in the Zuzia dashboard and install the agent.
  2. Create a scheduled task with the check commands below, then choose the hosts and how often it runs.
  3. Choose your notification channels. Turn on maintenance mode during planned work so it doesn't trigger alerts.

Best Practices for Email Queue Monitoring

1. Monitor Queue Size Continuously

  • Track queue size regularly
  • Alert when queue exceeds thresholds
  • Monitor queue processing rate
  • Investigate queue growth patterns

2. Monitor SMTP Server Performance

  • Track SMTP server availability
  • Monitor SMTP response times
  • Check SMTP error rates
  • Test SMTP connectivity regularly

3. Track Email Delivery Success

  • Monitor delivery success rates
  • Track bounce rates
  • Review delivery failures
  • Optimize email server configuration

4. Set Up Comprehensive Alerts

  • Configure alerts for queue size
  • Set up alerts for SMTP failures
  • Monitor email delivery failures
  • Alert on SMTP server unavailability

Troubleshooting Email Queue Issues

Step 1: Identify Email Problems

When email queue is large:

# Check queue size
mailq | wc -l

# View queue details
mailq

# Check SMTP server status
systemctl status postfix
systemctl status sendmail

Step 2: Resolve Email Issues

Based on investigation:

  1. Process Queue:

    # Process Postfix queue
    postqueue -f
    
    # Flush queue
    postfix flush
    
  2. Fix SMTP Issues:

    • Restart SMTP service
    • Fix SMTP configuration
    • Resolve network connectivity
  3. Optimize Email Delivery:

    • Optimize email server configuration
    • Improve delivery rates
    • Scale email infrastructure

FAQ: Common Questions About Email Queue Monitoring

How often should I check email queue?

For production email servers, continuous automated monitoring is essential. Zuzia.app can check email queue every few minutes, alerting you when queue size exceeds thresholds.

What is considered a large email queue?

Large email queue depends on your email volume. Generally, queues over 100 emails indicate potential issues, and queues over 500 emails require immediate attention. Set thresholds based on your email volume.

How do I monitor SMTP server performance?

Monitor SMTP server performance by testing SMTP connectivity, checking SMTP response times, monitoring SMTP error rates, and reviewing SMTP server logs. Zuzia.app can help automate this monitoring.

Can email monitoring impact email delivery?

Email monitoring commands have minimal impact on email delivery when done correctly. Use appropriate monitoring frequency and avoid monitoring during peak email sending periods.

Related guides, recipes, and problems

  • Related guides

    • guides--monitoring-email-delivery-smtp-reliability.md
    • guides--server-performance-monitoring-best-practices.md
  • Related recipes

    • recipes--monitor-system-log-entries-linux.md
  • Related problems

    • problems--email-delivery-failures-smtp-errors.md
    • problems--service-not-running-linux.md

We use cookies to ensure the proper functioning of our website.