Install send mail service on Fedora
Fedora: Install and Configure Authenticated Mail Sending with msmtp
and s-nail
Overview
This guide explains how to set up authenticated email sending from the command line on Fedora using msmtp (a lightweight SMTP client) and s-nail (a mailx-compatible mail utility). This method is ideal for scripts and system notifications in environments where only authenticated SMTP is allowed.
1. Install Required Packages
sudo dnf install msmtp s-nail
2. Configure msmtp
- Copy the example configuration (optional):
sudo cp /usr/share/doc/msmtp/msmtprc-system.example /etc/msmtprc
- Edit
/etc/msmtprc
and adjust to your SMTP provider:sudo nano /etc/msmtprc
Example configuration:
defaults auth on tls on tls_trust_file /etc/ssl/certs/ca-bundle.crt logfile /var/log/msmtp.log account default host mail.hosting.de port 587 from admin@simmy.org user admin@simmy.org password <super-secret>
- Set permissions to protect your password:
sudo chmod 600 /etc/msmtprc
3. Configure s-nail to Use msmtp
Add the following line to /etc/s-nail.rc
or your ~/.mailrc
:
set mta=/usr/bin/msmtp
4. Send a Test Email
echo "This is the body" | mail -s "Test Subject" recipient@example.com
- If the command returns no errors, the mail was sent successfully.
- Check
/var/log/msmtp.log
for troubleshooting if needed.
5. Notes
- If you receive an error like "Authenticated user is not permitted to override sender address", ensure the
from
address in/etc/msmtprc
matches the authenticated SMTP user, or configure your SMTP provider to allow the desired sender address. - For use in scripts (e.g., backup notifications), simply use the
mail
command as shown above.
No Comments