Для отправки оповещений в виде email устройствами, системами мониторинга и прочими админскими штуками зачастую в Exchange создаётся специальный коннектор для отправки таких сообщений без аутентификации. Конечно же, область действия такого коннектора административно ограничивается определёнными подсетями и адресами доверенных хостов. Однако отправка почты на домены, не входящие в число доверенных в организации Exchange, в коннекторе по-умолчанию запрещена. Если нужно отправить оповещалку внешнему получателю – проблема. В логе можно увидеть такое сообщение:
550 5.7.54 SMTP; Unable to relay recipient in non-accepted domain
Для того, чтобы разрешить отправку любому получателю через наш коннектор, необходимо выполнить команду, дающую соответствующие права анонимному юзеру:
Get-ReceiveConnector "MSK-MAIL2-01\Without Auth" | Add-ADPermission -User "NT AUTHORITY\ANONYMOUS LOGON" -ExtendedRights "Ms-Exch-SMTP-Accept-Any-Recipient"
Get-ReceiveConnector "MSK-MAIL2-01\Without Auth" | Get-ADPermission | sort user | where {$_.extendedrights -like "Ms-Exch-SMTP-Accept-Any-Recipient"} | ft User,ExtendedRights -auto
Чтение логов протокола SMTP может доставлять немало головной боли, если не уметь его читать. Здесь я продублирую кусок документации с сайта Микрософт, в котором рассказано, какие поля содержатся в логах SMTP, которые ведут посылающие и принимающие коннекторы Exchange.
The protocol log stores each SMTP protocol event on a single line in the log. The information stored on each line is organized by fields, and these fields are separated by commas. The fields that are used in the protocol log are described in the following table.
Field name
Description
date-time
UTC date-time of the protocol event. The UTC date-time is represented in the ISO 8601 date-time format: yyyy-mm-ddThh:mm:ss.fffZ, where yyyy = year, mm = month, dd = day, T indicates the beginning of the time component, hh = hour, mm = minute, ss = second, fff = fractions of a second, and Z signifies Zulu, which is another way to denote UTC.
connector-id
Distinguished name (DN) of the connector that’s associated with the SMTP event.
session-id
GUID value that’s unique for each SMTP session, but is the same for every event that’s associated with that SMTP session.
sequence-number
Counter that starts at 0 and is incremented for each event in the same SMTP session.
local-endpoint
Local endpoint of an SMTP session. This consists of an IP address and TCP port number formatted as <IP address>: <port>.
remote-endpoint
Remote endpoint of an SMTP session. This consists of an IP address and TCP port number formatted as <IP address>: <port>.
event
Single character that represents the protocol event. Valid values are: +: Connect -: Disconnect >: Send <: Receive *: Information
data
Text information associated with the SMTP event.
context
Additional contextual information that may be associated with the SMTP event.
One SMTP conversation that represents sending or receiving a single email message generates multiple SMTP events. Each event is recorded on a separate line in the protocol log. An Exchange server has many SMTP conversations going on at any given time. This creates protocol log entries from different SMTP conversations that are mixed together. You can use the session-id and sequence-number fields to sort the protocol log entries by each individual SMTP conversation.
Случай 1: Сервер не может доставить сообщение, ошибка 421 4.4.2 Connection dropped due to SocketError Решение: Смотрим лог. Фильтруем записи по session-id, последняя строка содержит с записи >,DATA, <,"354 Enter mail, end with ""."" on a line by itself.", -,,Remote Какой вывод можно сделать из этих строк? Сразу несколько. 1. Передача данных началась. Серверы успешно договорились о параметрах соединения, о получателях, все проверки антиспам пройдены и т.д. 2. Передача данных не завершилась. В случае успешного и корректного завершения приёма письма мы должны увидеть сообщение вида <,"250 Mail OK queued as mx12,duCowABnt9OspNlfOs+tAA--.3497S2 1608098992", которое говорит нам о том, что удалённый сервер принял к себе письмо. 3. Сессия была разорвана удалённым хостом. Об этом нам говорит символ “-” (минус), и подпись Remote. В штатном случае мы обычно видим -,,Local . Причины? Обрыв связи из-за нестабильного канала связи (вполне может быть воспринят как разрыв удалённым сервером), таймаут из-за слишком медленной передачи письма (большой объём, медленный канал). Необходимо уменьшить размер письма.
1. Run ADSI Edit tool: adsi.msc 2. Connect to 3. In connection settings Select a well known Naming Context – Configuration 4. Expand Configuration – Services – Microsoft Exchange – <Name of your Organization> – Administrative Groups – Exchange Administrative Group (FYDIBOHF23SPDLT) – Servers 5. Click Exchange server Properties 6. Clear msExchProductID attribute 7. Restart Microsoft Exchange Information Store service if server holds mailbox role 8. Enter New Product Key using Exchange Management Console or PowerShell