Microsoft 365 有三種常見設備寄信路徑,條件不同:587 authenticated submission、只寄租戶內的 direct send、用固定公網 IP 或憑證驗證的 SMTP relay。先選對模式再填 port。
確認網域與端點
查租戶 MXPowerShell
Resolve-DnsName contoso.com -Type MXDirect Send/SMTP Relay 通常使用租戶 MX endpoint,不是照抄範例。
測 smtp.office365.com 587PowerShell
Test-NetConnection smtp.office365.com -Port 587Client submission 仍需 STARTTLS 與支援的認證。
測租戶 MX 的 25PowerShell
Test-NetConnection contoso-com.mail.protection.outlook.com -Port 25把 endpoint 換成實際 MX;ISP/雲端可能擋 outbound 25。
測 587 STARTTLSOpenSSL
openssl s_client -connect smtp.office365.com:587 -starttls smtp -servername smtp.office365.com -brief只驗 TLS,不代表帳號可 AUTH。
測租戶 MX STARTTLSOpenSSL
openssl s_client -connect contoso-com.mail.protection.outlook.com:25 -starttls smtp -servername contoso-com.mail.protection.outlook.com -brief確認設備所在網路能建立 TLS。
SMTP AUTH 與 Connector 盤點
查看全租戶 SMTP AUTHExchange Online PowerShell
Get-TransportConfig | Format-List SmtpClientAuthenticationDisabled預設應停用,只有必要 mailbox 做例外。
查看單一設備帳號 SMTP AUTHExchange Online PowerShell
Get-CASMailbox [email protected] | Format-List SmtpClientAuthenticationDisabledFalse 表示單一信箱允許;Null 跟隨 tenant。
只對單一信箱啟用 SMTP AUTHExchange Online PowerShell
Set-CASMailbox [email protected] -SmtpClientAuthenticationDisabled $false確認安全預設、authentication policy 與 Basic Auth 狀態;能用 OAuth 就不要開。
重新讓信箱跟隨租戶設定Exchange Online PowerShell
Set-CASMailbox [email protected] -SmtpClientAuthenticationDisabled $null替代方案上線後撤掉例外。
查看 Inbound ConnectorExchange Online PowerShell
Get-InboundConnector | Format-List Name,Enabled,SenderIPAddresses,SenderDomains,RequireTls,TlsSenderCertificateNameSMTP relay connector 應鎖定專用公網 IP 或憑證。
查看 Accepted DomainsExchange Online PowerShell
Get-AcceptedDomain | Format-Table DomainName,DomainType設備 From address 應使用租戶接受的網域。
寄送後查證
依設備寄件者查 traceExchange Online PowerShell
Get-MessageTraceV2 -StartDate (Get-Date).AddHours(-6) -EndDate (Get-Date) -SenderAddress [email protected]確認 Microsoft 365 是否收到與最後狀態。
依收件者查 traceExchange Online PowerShell
Get-MessageTraceV2 -StartDate (Get-Date).AddHours(-6) -EndDate (Get-Date) -RecipientAddress [email protected]Direct Send 只能寄組織內部收件者。
查 SPFPowerShell
Resolve-DnsName contoso.com -Type TXT | Where-Object Strings -Match 'v=spf1'若 relay 從自有公網 IP 出站,SPF 需按整體寄送架構規劃。
查設備 DNS 與時間Windows/設備管理端
Resolve-DnsName smtp.office365.com; w32tm /query /status設備憑證驗證需要正確 DNS 與時間;非 Windows 設備用其內建診斷。
查看設備 IP 的 PTRPowerShell
Resolve-DnsName 203.0.113.25 -Type PTR使用 IP-based connector 時也要維持固定且乾淨的公網來源。
保存測試參數PowerShell
[pscustomobject]@{Time=Get-Date;Device='Scanner-01';Mode='SMTP Relay';Port=25;From='[email protected]'} | Export-Csv .\smtp-device-test.csv -Append -NoTypeInformation不記錄密碼或 token。
怎麼確認有做對
- 設備從實際 VLAN 寄到內部測試收件者,再依需求測外部。
- Message Trace 找得到同一封測試信,header 顯示預期 connector 與 SPF/DKIM。
- 完成後確認沒有為整個 tenant 開 SMTP AUTH,也沒有 Any IP relay。
常見錯誤
- 把 smtp.office365.com:587 和租戶 MX:25 混在一起。
- 為一台舊影印機停用全租戶 Security Defaults。
- Connector 使用共用 NAT IP,其他系統也能冒用 relay。
- 設備不支援 TLS/OAuth,卻假設改 port 就能解。
常見問題
影印機只支援帳密和 TLS 1.0 怎麼辦?
不要為它降低整個 Microsoft 365 安全性。可評估內部受控 SMTP relay、設備更新、OAuth-capable relay、High Volume Email 或 Azure Communication Services Email。
Direct Send 可以寄 Gmail 嗎?
不行,Direct Send 主要用於寄到 Microsoft 365 組織內收件者;要寄外部須用 authenticated submission、SMTP relay connector 或其他核准服務。
延伸閱讀
版本與官方文件
參數會隨工具版本與作業系統實作改變。正式環境先用 --help、-h 或系統內建說明確認,再以當版官方文件為準。
常見問題
影印機只支援帳密和 TLS 1.0 怎麼辦?
不要為它降低整個 Microsoft 365 安全性。可評估內部受控 SMTP relay、設備更新、OAuth-capable relay、High Volume Email 或 Azure Communication Services Email。
Direct Send 可以寄 Gmail 嗎?
不行,Direct Send 主要用於寄到 Microsoft 365 組織內收件者;要寄外部須用 authenticated submission、SMTP relay connector 或其他核准服務。