Test SMTP Mail Server With Telnet
Testing SMTP with telnet can come in handy. You may have just set up your mailserver and want to test it, or your email client is having problems sending emails and is not giving very helpful error messages (if any). Using telnet is handy as it will throw up any error messages which will help you do understand at what part of the sending process the failure has occured.
Testing with Telnet is real quick and simple,we are going to assume plain password authentication and no TLS or SSL.
- We need to open a connection to the server
$ telnet yourmailserver.com 25
You should get a response like this
Trying 74.125.79.16.. Connected to yourmailserver.com. Escape character is '^]'. 220 mx.yourmailserver.com
- Now we need to greet the serer
HELO yourmailserver.com
Response
250 yourmailserver.com
- We need to authenticate ourselves with our username and password. This may not be neccessary for all SMTP servers.
We are going to use plain authentication but we need to encode it to base64. Below is two ways to do this with Perl or PHP, with both methods you must leave in the “\0″ characters.$ php -r 'echo base64_encode("\0username\0password")."\n";'or
$ perl -MMIME::Base64 -e 'print encode_base64("\0username\0password");'Take the value given and pass it to the mail server
AUTH PLAIN AHVzZXJuYW1lAHBhc3N3b3Jk
Response
235 2.7.0 Authentication successful
- Now we start to send a test message by putting in who the mail is from
MAIL FROM:me@mydomain.com
Response
250 2.1.0 Ok
- Add recipient
RCPT TO:me@myotheremail.com
Response
250 2.1.5 Ok
- Add a subject
SUBJECT: Test message from me
- Start the message
DATA
Response
354 End data with <CR><LF>.<CR><LF>
Press enter then add the message body
Hi this is my test message
Press enter and on the next line type a “.” then enter
.
Response
250 2.0.0 Ok: queued as 666F4E0157
- Thats it the message is on the way now quit
QUIT
