sudo apt-get install msmtp-mta msmtp.

Конифг  — /etc/msmtprc

# Example for a system wide configuration file 
 
# A system wide configuration file is optional. 
# If it exists, it usually defines a default account. 
# This allows msmtp to be used like /usr/sbin/sendmail. 
account default 
 
# Mail.ru 
host    smtp.mail.ru 
auth    login 
user    user@mail.ru
from    user@mail.ru 
password    1234567


aliases    /etc/aliases
 
# Use TLS.
tls on
tls_trust_file /etc/ssl/certs/ca-certificates.crt

# Syslog logging with facility LOG_MAIL instead of the default LOG_USER.
syslog LOG_MAIL

 

echo "hello there username." | msmtp -a default sve@gmail.com

echo "hello there username." | msmtp  mail_from@mail.ru   mail_to@gmail.com
 

sudo nano /etc/mail.rc  — добавить строку set sendmail=/usr/bin/msmtp

sudo nano /etc/aliases

# Send everything to admin
default: your@mail.com