Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學
您现在的位置: Windows教程網 >> Windows教程 >  >> 電腦軟體教學 >> 伺服器技術 >> 關於伺服器

使用 Telnet 連接埠 25 測試 SMTP 通訊完整指南

編輯:關於伺服器

適用場景

  • 兩台 Exchange 伺服器間 SMTP 傳遞故障排查
  • 驗證外部主機能否連線至內部 SMTP 伺服器
  • 測試 SMTP 服務是否正常啟動 (預設監聽埠 25)

前置準備

  1. 目標收件人完整 SMTP 郵件地址 (格式:user@site.domain.com)。
  2. 目標 SMTP 伺服器 FQDN 或 IP (可用 nslookup -type=mx domain.com 查詢 MX 記錄)。
  3. 確認目標伺服器 SMTP 服務已啟動。
  4. Telnet 客戶端開啟本地回顯:set local_echo (XP 用 set localecho)。

基本測試流程 (手動 SMTP 對話)

> telnet mail.contoso.com 25
220 site.contoso.com Microsoft Exchange Internet Mail Connector <版本>

> EHLO test.com
250 OK

> MAIL FROM:Admin@test.com
250 OK - MAIL FROM Admin@test.com

> RCPT TO:User@Domain.Com
250 OK - Recipient User@Domain.Com

> DATA
354 Send data. End with CRLF.CRLF

> Subject: test message
>
> This is a test message
> .
250 OK

> QUIT
221 closing connection

關鍵指令說明

指令用途注意事項
EHLO / HELO初始化會話,宣告發件域EHLO 支援擴展 SMTP (ESMTP),優先使用
MAIL FROM指定寄件者建議使用有效地址,否則無法收到退信通知 (NDR)
RCPT TO指定收件者需為目標域實際存在的帳號,否則產生 NDR
DATA開始輸入郵件內容以單獨一行 . 結束
Subject:郵件主旨後需空一行 (RFC 822/2822 規範)
QUIT結束會話

進階測試:要求傳遞回條 (DSN)

在 RCPT TO 階段加入參數:

RCPT TO:User@Site.Domain.Com notify=success,failure

可驗證伺服器出站傳遞能力:若收件者收到郵件並回傳 DSN,代表雙向通訊正常。

常見錯誤代碼對照

  • 500 Command not recognized:指令拼寫錯誤或非 Microsoft SMTP 伺服器。
  • 421 Service not available:服務未啟動或連線數達上限。
  • 550 Relay access denied:開放轉發被拒,需驗證或加入允許清單。
  • 451 Requested action aborted:本地處理錯誤 (如磁碟滿、權限問題)。

Microsoft SMTP 版本差異

  • Windows/IIS 內建 SMTP 服務
  • Exchange 2000/2003 使用 IIS SMTP
  • Exchange 4.0/5.0/5.5 使用 IMC (Internet Mail Connector) / IMS
  • 所有版本 220 回應皆含「Microsoft」關鍵字
Copyright © Windows教程網 All Rights Reserved