Test SMTP with Telnet

Useful for finding problems with new installations.

  • telnet examplemailserver.com 25.
  • Key in “EHLO examplemailserver.com” and press enter.
  • Key in “MAIL FROM: sender@mydomain.com” and press enter.
  • Key in “RCPT TO: recipient@examplemailserver.com” and press enter.
  • Key in “DATA” and press enter.
  • Optionally add envelope headers (and leave a blank line between these header values and the message body):
    From: “me”
    To: “you”
    Subject: This is the subject line
    X-CustomHeader: This is a custom header
  • Key in your message body and press enter.
  • Key in ” . ” and press enter.
  • Check the mailbox.

Authentication
For servers that require authentication first encode the username and the password to base64 e.g.

echo myusername | openssl enc -base64
echo mypassword | openssl enc -base64

Then use the returned values when prompted. After the ehlo specify:

AUTH LOGIN

assuming it is supported.

Secure Protocols
The H Security provides info on using openssl to test secure connections to email and web services. So as an example testing SMTP (with STARTTLS) :

$ openssl s_client -host mail.irgendwo.de -port 25 -starttls smtp
CONNECTED(00000003)
[…]
250 HELP
ehlo test
250-Mailserver Hello loki [10.1.2.73]
250-SIZE 52428800
250-PIPELINING
250-AUTH PLAIN LOGIN
250 HELP

and to test IMAPS:

$ openssl s_client -host imap.irgendwo.de -port 993
[…]
* OK IMAP4 Ready 0.0.0.0 0001f994
1 Login user-ju secret
1 OK You are so in
2 LIST “” “*”
* LIST (\HasChildren) “.” “INBOX”
* LIST (\HasNoChildren) “.” “INBOX.AV”
[…]
2 OK Completed (0.130 secs 5171 calls)
3 logout
* BYE LOGOUT received
3 OK Completed

The H Security article also covers POP and HTTPS.

Leave a Reply

  • (will not be published)

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>