Установка msmtprc
sudo apt-get install msmtp-mta ca-certificates
sudo nano /etc/msmtprc
defaults
tls on
tls_starttls on
tls_certcheck off
tls_trust_file /etc/ssl/certs/ca-certificates.crtaccount default
host <smtp.example.net>
port 465
auth on
keepbcc on
user <username@example.net>
password <password>
from <username@example.net>
syslog LOG_MAIL
sudo nano /etc/php/7.4/apache2/php.ini
sendmail_path = /usr/bin/msmtp -t
echo "Test Mail." | msmtp -a default username@domain.com