Системийн мэйл SMTP-ээр илгээдэг болгож тохируулах

Дусал нэвтэрхий толь-с
apt-get install msmtp mailutils bsd-mailx
vim /etc/mail.rc

# Add:
set sendmail=/usr/bin/msmtp
alias root root<user@domain.tld>


vim /etc/msmtprc
# Set default values for all following accounts.
defaults

# Use the mail submission port 587 instead of the SMTP port 25.
port 587

# Always use TLS.
tls on
tls_starttls on

# Set a list of trusted CAs for TLS. The default is to use system settings, but
# you can select your own file.
#tls_trust_file /etc/ssl/certs/ca-certificates.crt

# The SMTP server of your ISP
account defaultaccount
host mail.domain.tld
from user@domain.tld
auth on
user user@domain.tld
password P@SSw0rd

# Set default account to isp
account default: defaultaccount

# Map local users to mail addresses
aliases /etc/aliases
chmod 600 /etc/msmtprc
vim /etc/aliases

Add:

root: user@domain.tld
default: user@domain.tld

Check:

echo "Hello World" | msmtp -d user@gmail.com

Test:

echo "Testing msmtp from ${HOSTNAME} with mail command" | mail -s "hi there" user@gmail.com