oeltayeb.com · Exchange Server Troubleshooting Toolkit

Reference

SMTP protocol log reference

Based on the article: SMTP protocol logging on Exchange: reading send and receive logs to debug connections · 5 min read

Message tracking tells you what Exchange did with a message; SMTP protocol logs show what was said on the wire. When a device can't relay or TLS quietly fails, the answer is usually a few lines in a protocol log. In this post I'll show how to enable logging where you need it, where the files live and how to read a session to spot TLS, authentication and relay failures.

How protocol logging works

Default folders, under %ExchangeInstallPath%TransportRoles\Logs\:

ServiceReceive logsSend logs
Front End TransportFrontEnd\ProtocolLog\SmtpReceiveFrontEnd\ProtocolLog\SmtpSend
Transport (Mailbox server)Hub\ProtocolLog\SmtpReceiveHub\ProtocolLog\SmtpSend
Mailbox TransportMailbox\ProtocolLog\SmtpReceive\DeliveryMailbox\ProtocolLog\SmtpSend\Submission
Edge TransportEdge\ProtocolLog\SmtpReceiveEdge\ProtocolLog\SmtpSend

File names follow RECVyyyyMMddhh-nnnn.log and SENDyyyyMMddhh-nnnn.log, with the hour in UTC.

Step-by-step

1. Find the connector that handles the conversation

powershell
Get-ReceiveConnector -Server EX01 | Format-Table Name, TransportRole, Bindings, RemoteIPRanges, ProtocolLoggingLevel -AutoSize
Get-SendConnector | Format-Table Name, AddressSpaces, SmartHosts, ProtocolLoggingLevel -AutoSize

For inbound sessions, match the sender's IP and the port to Bindings and RemoteIPRanges; when several connectors listen on the same IP and port, the most specific matching range wins. TransportRole tells you the folder: FrontendTransport logs under FrontEnd, HubTransport under Hub. Outbound, the Send connector with the most specific matching address space is used.

2. Turn on verbose logging

powershell
Set-ReceiveConnector "EX01\Relay - Scanners" -ProtocolLoggingLevel Verbose
Set-SendConnector "Internet via Smart Host" -ProtocolLoggingLevel Verbose
# Server-to-server hops inside the organization (Transport service)
Set-TransportService EX01 -IntraOrgConnectorProtocolLoggingLevel Verbose

# Check folders and limits
Get-FrontendTransportService EX01 | Format-List ReceiveProtocolLog*, SendProtocolLog*
Get-TransportService EX01 | Format-List ReceiveProtocolLog*, SendProtocolLog*

Allow a few minutes for the change to be picked up, then reproduce the problem. On a busy server, raise ReceiveProtocolLogMaxAge or ReceiveProtocolLogMaxDirectorySize (and the Send equivalents) if files are recycled before you can read them.

3. Pull one session out of the file

Sessions are interleaved, so parse the file and filter by remote IP, then by session:

powershell
$dir = Join-Path $env:ExchangeInstallPath "TransportRoles\Logs\FrontEnd\ProtocolLog\SmtpReceive"
$file = Get-ChildItem $dir -Filter "RECV*.log" | Sort-Object LastWriteTime | Select-Object -Last 1
$fields = 'date-time','connector-id','session-id','sequence-number','local-endpoint','remote-endpoint','event','data','context'
$rows = Get-Content $file.FullName | Where-Object { $_ -notlike '#*' } | ConvertFrom-Csv -Header $fields

$rows | Where-Object { $_.'remote-endpoint' -like '192.168.10.50:*' } |
  Group-Object 'session-id' | Select-Object -Last 1 -ExpandProperty Group |
  Format-Table 'sequence-number', event, data, context -Wrap

4. Read the session

A healthy anonymous relay session looks like this (trimmed to sequence, event, data and context):

0   +
1   *   SMTPSubmit SMTPAcceptAnyRecipient SMTPAcceptAnySender ...   Set Session Permissions
2   >   220 mail.contoso.com Microsoft ESMTP MAIL Service ready at ...
3   <   EHLO scanner01.contoso.com
4   >   250  mail.contoso.com Hello [192.168.10.50] SIZE ... PIPELINING DSN ENHANCEDSTATUSCODES STARTTLS ...
5   <   STARTTLS
6   >   220 2.0.0 SMTP server ready
7   *   TLS protocol SP_PROT_TLS1_2_SERVER negotiation succeeded using bulk encryption algorithm ...
...
12  <   MAIL FROM:<scanner@contoso.com>
13  >   250 2.1.0 Sender OK
14  <   RCPT TO:<anna@fabrikam.com>
15  >   250 2.1.5 Recipient OK
16  <   DATA
17  >   354 Start mail input; end with <CRLF>.<CRLF>
18  >   250 2.6.0 <...> [InternalId=...] Queued mail for delivery
19  <   QUIT
20  >   221 2.0.0 Service closing transmission channel
21  -

5. Spot TLS, authentication and relay failures

In the logMeaningNext step
No STARTTLS in the EHLO responseNo usable certificate for the connectorSee Event ID 12014
TLS negotiation failed with error NoCredentials (send log)The certificate used for outbound TLS has no private keyInstall a valid certificate with its private key and enable it for SMTP
TLS negotiation failed with error UnknownCredentialsThe certificate named in TlsCertificateName isn't enabled for SMTPEnable-ExchangeCertificate -Services SMTP, then recheck TlsCertificateName
TLS negotiation failed with error SocketError; queue shows 421 4.4.2 Connection dropped due to SocketErrorThe handshake was dropped; Microsoft documents this when a server still uses TLS 1.0/1.1 with Microsoft 365Enable TLS 1.2 on the server
451 5.7.3 Must issue a STARTTLS command firstThe receiving side requires TLS and no STARTTLS happenedFix TLS on the sending side
TLS negotiation failed with error AlgorithmMismatchNo shared protocol version or cipher; admins report it mostly with older devicesUpdate the device's firmware or TLS settings
535 5.7.3 Authentication unsuccessfulWrong credentials, or a locked or disabled accountTest the account and the user name format the device sends
530 5.7.1 Client was not authenticatedAnonymous session on a connector that requires authenticationCheck connector-id: the device usually hit the wrong connector
550 5.7.54 SMTP; Unable to relay recipient in non-accepted domainAnonymous session without relay permissionUse a dedicated relay connector scoped to the device's IP

Verify

Tips & gotchas

References