Установка и настройка SMTP-клиента MSMTP на Debian

# Устанавливаем пакет msmtp и зависимости.

apt-get install msmtp msmtp-mta ca-certificates -y

# Создаем файл конфигурации

nano /etc/msmtprc

# Пример конфигурации msmtp на примере учетной записи Exchange Online (office365)

# ------------------------------------------------------------------------------
# Configuration file
# ------------------------------------------------------------------------------

# A system wide configuration is optional.
# If it exists, it usually defines a default account.
# This allows msmtp to be used like /usr/sbin/sendmail.

# ------------------------------------------------------------------------------
# Accounts
# ------------------------------------------------------------------------------

account exchanceonline
host smtp.office365.com
port 587
from no-reply@contoso.com
auth on
user no-reply@contoso.com
password secret
syslog LOG_MAIL

logfile /var/log/msmtp.log

# ------------------------------------------------------------------------------
# Configurations
# ------------------------------------------------------------------------------

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

# Set a default account
account default : exchanceonline

aliases /etc/aliases
# ------------------------------------------------------------------------------#

 

Пример как указываются aliases для пользователей (прим. root). Если файл /etc/aliases не существует, то создайте его.

root: admin@contoso.com

Проверить работу и корректность настройки почтового профиля msmtp можно командой:

echo -e "Subject: Test Mail\r\n\r\nThis is a test mail" | msmtp --debug -t admin@contoso.com

Читать далее