This document explains two supported ways to enable email sending from a Linux server:
- Direct delivery from the server itself (no external SMTP relay)
- Delivery via an external SMTP server (relay / smarthost)
Both approaches work with tools like mail, mailx, sendmail, and monitoring scripts (such as RAID alerts).
This method sends email directly from your server to the recipient's mail server using SMTP.
This is equivalent to how cPanel/Exim works by default.
- No external SMTP provider
- No authentication
- Uses the server's IP address
- Likely to be marked as spam (expected for testing)
- Best for internal alerts, testing, or isolated environments
apt update
apt install postfix mailutilsDuring installation (or via reconfiguration), choose:
- General type of mail configuration:
Internet Site - System mail name: your hostname (e.g.
server.example.com)
If Postfix was already installed but not configured:
dpkg-reconfigure postfixsystemctl restart postfix
systemctl status postfixYou should see:
Active: active (running)
echo "Direct mail test from $(hostname)" | \
mail -s "Mail test" you@example.comCheck logs:
tail -f /var/log/mail.logExpected behaviour:
- Postfix looks up recipient MX
- Attempts SMTP delivery
- Mail may be delayed, spam-filtered, or rejected — this is still success
Some hosting providers block outbound traffic on port 25 by default, which prevents direct mail delivery.
HyberHost does not block port 25 for new customers. We only restrict it if an IP address generates abuse complaints, ensuring responsible use while allowing direct mail for testing and alerts.
Test:
nc -vz gmail-smtp-in.l.google.com 25If blocked, direct delivery will fail.
Not required for testing, but affects deliverability.
hostname -f✔ Monitoring alerts (RAID, disk, uptime) ✔ Internal systems ✔ Temporary testing
❌ Transactional or user-facing email
This method relays all outgoing mail through a third-party SMTP server.
Examples:
- Google Workspace
- Microsoft 365
- Mailgun
- SendGrid
- ISP SMTP servers
- Requires authentication
- Better deliverability
- Works even if port 25 is blocked
- Recommended for production alerts
apt install postfix mailutilsChoose:
- General type:
Internet Site
Edit:
nano /etc/postfix/main.cfAdd or modify:
relayhost = [smtp.example.com]:587
smtp_use_tls = yes
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crtnano /etc/postfix/sasl_passwdFormat:
[smtp.example.com]:587 username:password
Secure and apply:
chmod 600 /etc/postfix/sasl_passwd
postmap /etc/postfix/sasl_passwd
systemctl restart postfixecho "Relay test" | mail -s "SMTP relay test" you@example.comThis is ideal for simple alerting scripts.
apt install msmtp msmtp-mtadefaults
auth on
tls on
logfile /var/log/msmtp.log
account relay
host smtp.example.com
port 587
user username
password password
from alerts@example.com
account default : relaySecure it:
chmod 600 /etc/msmtprcecho "msmtp test" | mail -s "msmtp test" you@example.com| Use case | Recommended method |
|---|---|
| Quick testing | Direct delivery (Postfix) |
| RAID / system alerts | Direct or relay |
| VPS with blocked port 25 | SMTP relay |
| Production alerting | SMTP relay |
| No daemon wanted | msmtp |
All methods above support:
echo "message" | mail -s "subject" recipient@example.comWhich means no script changes are required.
Your monitoring scripts only need:
mailbinary- A working MTA or relay
Check logs:
tail -f /var/log/mail.logCheck sendmail path:
which sendmailCheck Postfix config:
postconf -n