Using Telnet To Talk To Mail Servers

Connecting to a mail server using Telnet is pretty straight forward and can be used both for security testing as well as actual communications. Debugging code and creating communication applications using the mail protocols might require debugging with these tools and below is a sample of how to connect and communicate with a mail server using telnet…

1. telnet mail.domain.com 25
This connection opens communications with the target mail server

2. EHLO mydomain.com
This tells the target server what domain is making the connection

3.  MAIL FROM:byname@mydomain.com
This tells the target server who is sending the email

4. RCPT TO:yourname@domain.com
This tells the target server who is to receive the email at their end

5. DATA
This tells the target server that the email content is about to be sent with the correct formatting

6. Subject: This is a test message
This is obvious

7. .
Type just a lonely period to close the subject line section

8. This is the message content, etc…
This is obvious too

9. .
Type another lonely period to close the content section

10. QUIT
This closes the connection to the mail server

If all went well, you would receive 250 OK messages or similar, else failures that you need to handle.