Thursday, May 3, 2012

Testing mail server with telnet

POP3

Connect to the server.
telnet mailserver.com pop3
Trying xxx.xxx.xxx.xxx...
Connected to mailserver.com.
Escape character is '^]'.
+OK Dovecot ready.
Login.

user me
+OK
pass mypassword
+OK Logged in.
list
+OK 1 messages:
1 855
retr 1
...

SMTP

Create encoded login details.
perl -MMIME::Base64 -e 'print encode_base64("username");'
perl -MMIME::Base64 -e 'print encode_base64("password");'
Contact server and login.
telnet mailserver.com smtp
EHLO mailserver.com
AUTH LOGIN
The server will ask for username.
334 VXNlcm5hbWU6
Enter the encoded username.
bWU6==
Similarly with password.
334 UGFzc3dvcmQ6
bWUxc3Q=
If all well then server returns.
235 2.0.0 Authentication successful
Cool, now send an email.
MAIL from:me@mailserver.com
250 2.1.0 Ok
RCPT to:them@gmail.com
250 2.1.5 Ok
DATA
354 End data with .
From: me@mailserver.com
To: them@gmail.com
Subject: Test Message

This is a test message.
.
250 2.0.0 Ok: queued as C5C2C7C231
Thanks to http://www.ndchost.com/wiki/mail/test-smtp-auth-telnet