Чтение логов протокола 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 .
Причины? Обрыв связи из-за нестабильного канала связи (вполне может быть воспринят как разрыв удалённым сервером), таймаут из-за слишком медленной передачи письма (большой объём, медленный канал). Необходимо уменьшить размер письма.