Я настроил Ms office 365 в postfix. Но я столкнулся с ошибкой при отправке электронного письма. Вот журнал.
AD0C147573: lost connection with smtp.office365.com[40.97.188.242] while sending RCPT TO
Oct 30 ipostfix/cleanup[28332]: B3998475A6: message-id=<20181031080058.B3998475A6@localhost>
Oct 30 postfix/bounce[28330]: AD0C147573: sender non-delivery notification: B3998475A6
to=<mail@example.in>, relay=smtp.office365.com[40.97.188.242]:587, delay=5, delays=0/0/0.02/5, dsn=5.7.57, status=bounced (host smtp.office365.com[40.97.188.242] said: 530 5.7.57 SMTP; Client was not authenticated to send anonymous mail during MAIL FROM [0PR0102CA0006.prod.exchangelabs.com] (in reply to MAIL FROM command)
Вывод postconf -n
alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
append_dot_mydomain = no
biff = no
config_directory = /etc/postfix
inet_interfaces = all
inet_protocols = ipv4
mydestination = ip-10-0-0-10, localhost, localhost.localdomain, , localhost
myhostname = localhost
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 ip-10-0-0-139
readme_directory = no
recipient_delimiter = +
relayhost = [smtp.office365.com]:587
sender_canonical_maps = regexp:/etc/postfix/sender_canonical
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_password
smtp_sasl_security_options = noanonymous
smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt
smtp_tls_note_starttls_offer = yes
smtp_tls_security_level = encrypt
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
smtp_use_tls = yes
smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
smtpd_tls_CAfile = /etc/ssl/certs/ca-certificates.crt
smtpd_tls_cert_file = /etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file = /etc/ssl/private/ssl-cert-snakeoil.key
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtpd_use_tls = yes
smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
Postfix работает на сервере ubuntu 16, также создаются записи MX и TXT.
Изменить: файл конфигурации Postfix
smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
smtpd_use_tls=yes
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
# information on enabling SSL in the smtp client.
smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
myhostname = ip-10-0-0-10
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
mydestination = ip-10-0-0-10, localhost.localdomain, , localhost
relayhost =[smtp.office365.com]:587
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options =
smtp_tls_security_level = encrypt
mailbox_command = procmail -a "$EXTENSION"
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
inet_protocols = ipv4
Я отправляю электронное письмо по почте.
echo "Test Message" | mail -s "Test Subject" abc@gmail.com
В сообщении об ошибке говорится:
Клиент не прошел аутентификацию для отправки анонимной почты во время MAIL FROM
Это означает, что принимающий почтовый хост (office365) не разрешает адресу «Почта от» использовать сервер ретрансляции. Сначала проверьте правильность имени пользователя и пароля SASL.
smtp_sasl_password_maps = hash:/etc/postfix/sasl_password
Проверьте другие требования, указанные в
https://support.office.com/en-us/article/How-to-set-up-a-multifunction-device-or-application-to-send-email-using-Office-365-69f58e99-c550-4274-ad18-c805d654b4c4