Search This Blog

Saturday 2 June 2012

Use Telnet on Port 25 to test SMTP communication

For purposes of providing an example, the following procedure uses the values that are described in the following list:

* Destination SMTP server mail1.fabrikam.com
* Source domain contoso.com
* Sender's e-mail address chris@contoso.com
* Recipient's e-mail address kate@fabrikam.com
* Message subject Test from Contoso
* Message body This is a test message
Bb123686.note(en-us,EXCHG.141).gifNote:
You should always use a valid sender e-mail address so that any non-delivery report (NDR) messages that are generated by the destination SMTP server are delivered to the sender of the message.

The commands in Telnet Client are not case-sensitive. The SMTP command verbs are capitalized for clarity.

1. At a command prompt, type telnet, and then press ENTER. This command opens the Telnet session.
2. Type set localecho and then press ENTER. This optional command lets you view the characters as you type them. This setting may be required for some SMTP servers.
3. Type set logfile <filename>. This optional command enables logging of the Telnet session to the specified log file. If you only specify a file name, the location of the log file is the current working directory. If you specify a path and a file name, the path must be local to the computer. Both the path and the file name that you specify must be entered in the Microsoft DOS 8.3 format. The path that you specify must already exist. If you specify a log file that doesn't exist, it will be created for you.
4. Type open mail1.fabrikam.com 25 and then press ENTER.
Bb123686.note(en-us,EXCHG.141).gifNote:
You can't use the backspace key after you have connected to the destination SMTP server within the Telnet session. If you make a mistake as you type an SMTP command, you must press ENTER and then type the command again. Unrecognized SMTP commands or syntax errors result in an error message that resembles the following:

500 5.3.3 Unrecognized command

5. Type EHLO contoso.com and then press ENTER.
6. Type MAIL FROM:chris@contoso.com and then press ENTER.
7. Type RCPT TO:kate@fabrikam.com NOTIFY=success,failure and then press ENTER. The optional NOTIFY command defines the particular delivery status notification (DSN) messages that the destination SMTP server must provide to the sender. DSN messages are defined in RFC 1891. In this case, you're requesting a DSN message for successful or failed message delivery.
8. Type DATA and then press ENTER. You will receive a response that resembles the following:

354 Start mail input; end with <CLRF>.<CLRF>

9. Type Subject: Test from Contoso and then press ENTER.
10. Press ENTER. RFC 2822 requires a blank line between the Subject: header field and the message body.
11. Type This is a test message and then press ENTER.
12. Press ENTER, type a period ( . ) and then press ENTER. You will receive a response that resembles the following:

250 2.6.0 <GUID> Queued mail for delivery

13. To disconnect from the destination SMTP server, type QUIT and then press ENTER. You will receive a response that resembles the following:

221 2.0.0 Service closing transmission channel

14. To close the Telnet session, type quit and then press ENTER.

No comments:

Post a Comment