Hostxpeed
Login Get Started →
Getting Started

How to Set Up Email Alerts

4 min read
21 views
Jun 10, 2026

Prerequisites

Before setting up email alerts, make sure you have:

  • SSH access to your VPS
  • Root or sudo privileges

Install mailutils

Connect to your VPS:

ssh hxroot@YOUR_SERVER_IP -p 22
apt install mailutils -y

During installation, select "Internet Site" and enter your domain.

Test Email Sending

echo "Test email" | mail -s "Test Subject" your-email@example.com

Disk Usage Alert Script

#!/bin/bash
THRESHOLD=85
USAGE=$(df -h / | awk ''NR==2 {print $5}'' | sed ''s/%//'')
if [ $USAGE -gt $THRESHOLD ]; then
    echo "Warning: Disk usage is at ${USAGE}% on $(hostname)" | mail -s "Disk Alert: $(hostname)" admin@example.com
fi

Add to cron:

0 9 * * * /root/disk_alert.sh

Failed Login Alert

#!/bin/bash
FAILED=$(grep "Failed password" /var/log/auth.log | tail -10)
if [ ! -z "$FAILED" ]; then
    echo "$FAILED" | mail -s "Failed SSH Attempts on $(hostname)" admin@example.com
fi

✅ Email alerts have been configured.

Was this article helpful?