Чтобы сервер отправлял письма и они доходили на бесплатные почтовые сервисы, нужно настроить отправку, через реальный почтовый ящик. Proxmox использует для этого Postfix. Настроим его.
Откроем консоль сервера и доставим недостающие модули
Код: Выделить всё
apt install postfix-pcre libsasl2-modules
Код: Выделить всё
cp /etc/postfix/main.cf /etc/postfix/main.cf.bak
Код: Выделить всё
nano /etc/postfix/main.cf
Создаем хеш файл авторизации для доступа к почтовому ящику. Далее по коду везде вместо youremail и yourpassword подставьте ваш логин и пароль# See /usr/share/postfix/main.cf.dist for a commented, more complete version
myhostname=pve1.hserv.su
default_transport = smtp
smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU)
biff = no
# appending .domain is the MUA's job.
append_dot_mydomain = no
# Uncomment the next line to generate "delayed mail" warnings
#delay_warning_time = 4h
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
mydestination = $myhostname, localhost.$mydomain, localhost
relayhost = [smtp.yandex.ru]:587
mynetworks = 127.0.0.0/8
inet_interfaces = loopback-only
recipient_delimiter = +
compatibility_level = 2
header_checks = pcre:/etc/postfix/rewrite_subject
smtp_sender_dependent_authentication = yes
sender_dependent_relayhost_maps = hash:/etc/postfix/sender_relayhost.hash
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_auth.hash
smtp_sasl_security_options = noanonymous
smtp_use_tls = yes
smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt
smtp_generic_maps = hash:/etc/postfix/generic
Откроем файл
Код: Выделить всё
nano /etc/postfix/sasl_auth.hash
Код: Выделить всё
[smtp.yandex.ru]:587 youremail@yandex.ru:yourpassword
Код: Выделить всё
nano /etc/postfix/sender_relayhost.hash
Код: Выделить всё
youremail@yandex.ru [smtp.yandex.ru]:587
Код: Выделить всё
nano /etc/postfix/generic
Код: Выделить всё
root@yournameserver youremail@yandex.ru
Зашифруем файлы с помощью postmap
Код: Выделить всё
postmap /etc/postfix/sender_relayhost.hash
Код: Выделить всё
postmap /etc/postfix/sasl_auth.hash
Код: Выделить всё
postmap /etc/postfix/generic
Код: Выделить всё
chmod 0600 /etc/postfix/sasl_auth.*
Код: Выделить всё
nano /etc/postfix/rewrite_subject
Код: Выделить всё
/^Subject: (.*)$/ REPLACE Subject: [pve]: $1
На этом настройка Postfix закончена, осталось применить внесенные настройки
Код: Выделить всё
service postfix restart
Код: Выделить всё
echo "Test from proxmox" | mail -s test my-email@mail.ru
То поставим следующий пакет-bash: mail: command not found
Код: Выделить всё
apt install mailutils -y