Sending Email using s-nail on RHEL 9 with Enhanced Security Measures
Sending Email using s-nail on RHEL 9 with Enhanced Security Measures
In Red Hat Enterprise Linux 9 (RHEL 9), sending emails through the command line can be accomplished using s-nail, a feature-rich implementation of the mailx command. This medium will guide you through the process of configuring s-nail to send emails securely using SMTP with STARTTLS and login authentication.

Prerequisites
Before you proceed, ensure that s-nail is installed on your RHEL 9 system:
dnf install s-nail
Configuring s-nail for Secure Email Transmission
Editing the .mailrc Configuration File
To configure s-nail for sending emails securely, you need to edit the .mailrc file located in the root or other user directory:
vi /root/.mailrc
# Please do not forget switch to user For postgres and other user
su - postgres
vi .mailrc
Add the following configurations to enable STARTTLS, disable SSL/TLS certificate verification, and set SMTP server details along with authentication credentials:
set smtp-use-starttls
set ssl-verify=ignore
set smtp=10.6.120.120:25
#[SMTP-SERVER]:[SMTP-SERVER-PORT]
set smtp-auth=login
set smtp-auth-user=bilgi@itu.edu.tr
# Sender adresses
set smtp-auth-password=password
smtp-use-starttls: Enables STARTTLS to establish an encrypted connection for SMTP sessions, enhancing email traffic security.ssl-verify=ignore: Disables SSL/TLS certificate verification. While this may reduce security, it's set here based on your provided configuration.smtp: Specifies the SMTP server address and port.smtp-auth: Enables login authentication for SMTP.smtp-auth-userandsmtp-auth-password: Specifies the email address and password for SMTP authentication.
Save and close the .mailrc file.
Sending a Test Email
Now, you can send a test email using the mailx command with verbose output to reciver:
mailx -v -s "Test Email Subject" -r bilgi@itu.edu.tr ozk17@itu.edu.tr < /root/deneme.txt
-v: Enables verbose output to display detailed information about the email sending process.-s "Test Email Subject": Specifies the subject of the email.-r bilgi@itu.edu.tr: Sets the sender email address.ozk17@itu.edu.tr: Specifies the recipient email address.< /root/deneme.txt: Sends the content of/root/deneme.txtas the email body.
Conclusion
Configuring s-nail on RHEL 9 for sending emails securely involves enabling STARTTLS for encrypted connections, setting SMTP server details, and providing authentication credentials. While disabling SSL/TLS certificate verification may reduce security, it's essential to understand its implications and weigh them against your specific requirements.
By following the steps outlined in this guide, you can send emails securely using s-nail on RHEL 9, ensuring the confidentiality and integrity of your email communications. For more detailed and technical articles like this, keep following our blog on Medium. If you have any questions or need further assistance, feel free to reach out in the comments below and directly.
← PostgreSQL Blog