Table of Contents
Installing mailx on RHEL 9 allows you to send emails directly from the command line, which is useful for system alerts, scripts, and server monitoring.
STEP 1: Update the System
Before installing mailx, update your system packages to avoid dependency issues.
sudo dnf update -y
STEP 2: Install mailx Package
On RHEL 9, the mailx command is provided by the s-nail package.After installation, the mailx command becomes available system-wide.
sudo dnf install s-nail -y
STEP 3: Verify mailx Installation
Check that mailx is installed correctly by confirming its version.If the command runs without errors, mailx is installed successfully.
mailx -V
STEP 4: Send a Test Email Using mailx
Use this command to send a simple test email.Replace [email protected] with a valid email address.
echo "Test email from RHEL 9" | mailx -s "mailx Test" [email protected]
STEP 5: Configure mailx with SMTP
To send emails externally, configure SMTP settings in the mailx configuration file.Save the file and test email delivery again.
nano ~/.mailrc
Add the following example configuration:
set smtp=smtp://smtp.example.com:587
set smtp-auth=login
set [email protected]
set smtp-auth-password=your_password
set [email protected]
set ssl-verify=ignore
STEP 6: Test Email Delivery
Send another test email to confirm SMTP configuration.If the email arrives, mailx is fully configured.
echo "SMTP test successful" | mailx -s "mailx SMTP Test" [email protected]
STEP 7: Common Issues and Fixes
During or after installing mailx on RHEL 9, you may encounter a few common issues related to missing packages, SMTP configuration, or email delivery.
sudo dnf install mailx -y
Verify installation:
mailx -V
