2026-03-13 10:54:55 +01:00
|
|
|
# How to send an email from Linux in command line using a TLS SMTP server
|
2026-03-13 10:51:56 +01:00
|
|
|
|
2026-03-13 10:54:55 +01:00
|
|
|
## Configure msmtp for TLS
|
2026-03-13 10:51:56 +01:00
|
|
|
|
2026-03-13 11:14:48 +01:00
|
|
|
Install `msmtp`:
|
|
|
|
|
```bash
|
|
|
|
|
dnf install msmtp
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
Create `/etc/msmtprc`:
|
|
|
|
|
```
|
|
|
|
|
defaults
|
|
|
|
|
auth on
|
|
|
|
|
tls on
|
|
|
|
|
tls_trust_file /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem
|
|
|
|
|
logfile /var/log/msmtp.log
|
|
|
|
|
|
|
|
|
|
account default
|
|
|
|
|
host smtp.orange.fr
|
|
|
|
|
port 587
|
|
|
|
|
from plesnila.valeriu@orange.fr
|
|
|
|
|
user plesnila.valeriu@orange.fr
|
|
|
|
|
password "*****"
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
Test:
|
2026-03-13 10:51:56 +01:00
|
|
|
```bash
|
|
|
|
|
printf "Subject: Test Email\n\nThis is a test email." | msmtp -v vplesnila@gmail.com
|
|
|
|
|
```
|