mail
, msmtp
, or sendmail
for sending emails.msmtp
: A simple-to-configure SMTP client.mailutils
: For the mail
command.sudo apt update
sudo apt install msmtp mailutils
sudo yum install msmtp mailx
msmtp
Create the file ~/.msmtprc
:
nano ~/.msmtprc
Example configuration for Gmail:
account default
host smtp.gmail.com
port 587
auth on
user your.email@gmail.com
password your_password
tls on
tls_starttls on
logfile ~/.msmtp.log
Set file permissions:
chmod 600 ~/.msmtprc
Install Postfix (for Debian/Ubuntu):
sudo apt install postfix
For RHEL/CentOS:
sudo yum install postfix
During installation, select "Internet Site" as the configuration type.
Edit the main configuration file /etc/postfix/main.cf
:
myhostname = your-hostname
mydomain = your-domain.com
myorigin = $mydomain
inet_interfaces = all
relayhost =
Restart Postfix after changes:
sudo systemctl restart postfix
Send a test email:
echo "This is a test email" | mail -s "Postfix Test" recipient@example.com
echo "Here is the attached file" | mail -s "Subject" -A /path/to/file recipient@example.com
echo "Multiple files attached" | mail -s "Subject" -A /path/to/file1 -A /path/to/file2 recipient@example.com
Log in to the Hetzner DNS Console:
Add a TXT Record for SPF:
@ IN TXT "v=spf1 mx a ip4:YOUR_IP_ADDRESS ~all"
Generate a DKIM Key:
opendkim-genkey -s default -d your-domain.com
Add the Public Key to Hetzner DNS:
default.txt
file as a new TXT record:
default._domainkey IN TXT "v=DKIM1; k=rsa; p=PUBLIC_KEY_HERE"
Add the DMARC Record:
_dmarc IN TXT "v=DMARC1; p=none; rua=mailto:report@your-domain.com"
For stricter rules:
_dmarc IN TXT "v=DMARC1; p=reject; rua=mailto:report@your-domain.com"
dig TXT your-domain.com
msmtp
and mailutils
.Good luck sending emails! 😊