# Install send mail service on Fedora

## 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

```bash
sudo dnf install -y msmtp s-nail
```

## 2. Configure msmtp

1. Copy the example configuration (optional): ```
    sudo cp /usr/share/doc/msmtp/msmtprc-system.example /etc/msmtprc
    ```
2. Edit `/etc/msmtprc` and adjust to your SMTP provider: ```
    sudo nano /etc/msmtprc
    ```
    
    Example configuration:
    
    ```yaml
    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>
    ```
3. Set permissions to protect your password: ```bash
    sudo chmod 600 /etc/msmtprc 
    ```

## 3. Configure s-nail to Use msmtp

Add the following line to `/etc/s-nail.rc` or your `~/.mailrc`:

```ini
set mta=/usr/bin/msmtp
```

## 4. Send a Test Email

```bash
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.

## References

- [Sending e-mails via mailbox.org with msmtp on Fedora](https://zaage.it/tutorials/sending-emails-via-mailboxorg-with-msmtp-on-fedora/)
- [Fedora Docs: Mail Servers](https://docs.fedoraproject.org/en-US/fedora/f40/system-administrators-guide/servers/Mail_Servers/)
- [Fedora Forum: Sending mail with the (mailx) command](https://forums.fedoraforum.org/showthread.php?318795-Sending-mail-with-the-%28mailx%29-command)