How to test SMTP server via TELNET connection
In this post we will show you how to talk to the SMTP server via TELNET connection to test if MAIL server works. We have two cases, one when SMTP server doesn’t need users to authenticate – this can happen when you want to send email to the recipient inside your organization and you are connecting from the corporate network. The second case is when SMTP server needs you to authenticate before sending email. At first you need to connect to the SMTP server, enter the following command:
telnet [SMTP_SERVER_NAME] [PORT]
where
[SMTP_SERVER_NAME]
– is the IP address or network name of your SMTP server
[PORT]
– SMTP server port, the default value is 25
When you you see code 220 and server’s welcome message after connecting to it you are ready to start talking to the server.
Testing SMTP via TELNET with no authentication required
HELO [MAIL-SERVER-DOMAIN] // server responds with code 250 MAIL FROM: [SENDER-EMAIL-ADDRESS] // server responds with code 250 RCPT TO: [RECIPIENT-EMAIL-ADDRESS] // server responds with code 250 DATA // server responds with code 354 (now you need to enter mail) From: [SENDER-EMAIL-ADDRESS] To: [RECIPIENT-EMAIL-ADDRESS] Subject: [EMAIL-TITLE] [EMAIL-BODY] . (period ends email) // server responds with code 250 with the message that email was queued for delivery quit // server responds with code 221 and disconnects your connection
where:
[MAIL-SERVER-DOMAIN]
– this is your mail domain
[SENDER-EMAIL-ADDRESS]
– this is the sender’s email address
[RECIPIENT-EMAIL-ADDRESS]
– this is the recipient’s email address
[EMAIL-TITLE]
– this is email title
[EMAIL-BODY]
– this is email body
Testing SMTP via TELNET with authentication required
EHLO [MAIL-SERVER-DOMAIN] // server responds with code 250 AUTH LOGIN // server responds and prompts for your username [USERNAME] (depending on the SMTP server this value needs to be BASE64 encoded) // server responds and prompts for your password [PASSWORD] (depending on the SMTP server this value needs to be BASE64 encoded) // server responds and now you can follow the standard procedure of sending email MAIL FROM: [SENDER-EMAIL-ADDRESS] // server responds with code 250 RCPT TO: [RECIPIENT-EMAIL-ADDRESS] // server responds with code 250 DATA // server responds with code 354 (now you need to enter mail) From: [SENDER-EMAIL-ADDRESS] To: [RECIPIENT-EMAIL-ADDRESS] Subject: [EMAIL-TITLE] [EMAIL-BODY] . (period ends email) // server responds with code 250 with the message that email was queued for delivery quit // server responds with code 221 and disconnects your connection
where:
[MAIL-SERVER-DOMAIN]
– this is your mail domain
[USERNAME]
– this is your username (might be BASE64 encoded)
[PASSWORD]
– this is your password (might be BASE64 encoded)
[SENDER-EMAIL-ADDRESS]
– this is the sender’s email address
[RECIPIENT-EMAIL-ADDRESS]
– this is the recipient’s email address
[EMAIL-TITLE]
– this is email title
[EMAIL-BODY]
– this is email body
Leave a Reply
Want to join the discussion?Feel free to contribute!