SMTP: Difference between revisions

From miki
Jump to navigation Jump to search
No edit summary
Line 27: Line 27:
quit
quit
<font color="gray">221 2.0.0 srv1.dpetri.net Service closing transmission channel</font>
<font color="gray">221 2.0.0 srv1.dpetri.net Service closing transmission channel</font>

== AUTH PLAIN test script ==
See [http://qmail.jms1.net/test-auth.shtml] (more information at [http://www.fehcom.de/qmail/smtpauth.html])

First we need to compute the authentication string for the PLAIN authentication (this requires perl with MIME64 module installed):
<source lang="bash">
# Don't forget to escape any '@' in the perl string or it shall be interpret as an array variable!!!
perl -MMIME::Base64 -e 'print encode_base64("\000jms1\@jms1.net\000not.my.real.password")'
# AGptczFAam1zMS5uZXQAbm90Lm15LnJlYWwucGFzc3dvcmQ=
</source>

Example of script:
<source lang="bash">
nc smtp.server.org 587
</source>

{{gray|220 smtp.server.org ESMTP Postfix}}
ehlo griffin.hell
{{gray|250-smtp.priorweb.be}}
{{gray|250-PIPELINING}}
{{gray|250-SIZE}}
{{gray|250-VRFY}}
{{gray|250-ETRN}}
{{gray|250-STARTTLS}}
{{gray|250-AUTH PLAIN LOGIN}}
{{gray|250-AUTH=PLAIN LOGIN}}
{{gray|250-ENHANCEDSTATUSCODES}}
{{gray|250 8BITMIME}}
AUTH PLAIN AGptczFAam1zMS5uZXQAbm90Lm15LnJlYWwucGFzc3dvcmQ=
{{gray|235 2.7.0 Authentication successful}}
mail from: jms1@jms1.net
{{gray|250 2.1.0 Ok}}
rcpt to: jms1@jms1.net
{{gray|250 2.1.5 Ok}}
data
{{gray|354 End data with <CR><LF>.<CR><LF>}}
from: Jimmy <jms1@jms1.net>
to: Jimmy <jms1@jms1.net>
subject: test
test
.
{{gray|250 ok 1311459496 qp 15928}}
quit
{{gray|221 2.0.0 Bye}}

Note: '''EHLO''' is the more advanced helo command, that also lists the features supported by the server.

Revision as of 22:31, 23 July 2011

Testing SMTP

Tools

Same as for testing IMAP.

Test scripts

Simple test script found by Googling...

> telnet server 25

220 srv1.dpetri.net Microsoft ESMTP MAIL Service, Version: 5.0.2195.5329 ready at Sun, 15
Sep 2002 23:51:06 +0200
helo srv1.dpetri.net
250 srv1.dpetri.net Hello [192.168.0.100]
mail from: admin@petri.co.il
250 2.1.0 admin@petri.co.il....Sender OK
rcpt to: danielp@dpetri.net
250 2.1.5 danielp@dpetri.net
data
354 Start mail input; end with <CRLF>.<CRLF>
subject: this is a test
Hi Daniel
I'm trying to test this connection from Telnet.
Let me know if you get this message.

.
250 2.6.0 <SRV1zNQZO0KheDSZeTd00000002@srv1.dpetri.net> Queued mail for delivery
quit
221 2.0.0 srv1.dpetri.net Service closing transmission channel

AUTH PLAIN test script

See [1] (more information at [2])

First we need to compute the authentication string for the PLAIN authentication (this requires perl with MIME64 module installed):

# Don't forget to escape any '@' in the perl string or it shall be interpret as an array variable!!!
perl -MMIME::Base64 -e 'print encode_base64("\000jms1\@jms1.net\000not.my.real.password")' 
# AGptczFAam1zMS5uZXQAbm90Lm15LnJlYWwucGFzc3dvcmQ=

Example of script:

nc smtp.server.org 587
220 smtp.server.org ESMTP Postfix
ehlo griffin.hell
250-smtp.priorweb.be
250-PIPELINING
250-SIZE
250-VRFY
250-ETRN
250-STARTTLS
250-AUTH PLAIN LOGIN
{{{1}}}
250-ENHANCEDSTATUSCODES
250 8BITMIME
AUTH PLAIN AGptczFAam1zMS5uZXQAbm90Lm15LnJlYWwucGFzc3dvcmQ=
235 2.7.0 Authentication successful
mail from: jms1@jms1.net
250 2.1.0 Ok
rcpt to: jms1@jms1.net
250 2.1.5 Ok
data
354 End data with <CR><LF>.<CR><LF>
from: Jimmy <jms1@jms1.net>
to: Jimmy <jms1@jms1.net>
subject: test

test
.
250 ok 1311459496 qp 15928
quit
221 2.0.0 Bye

Note: EHLO is the more advanced helo command, that also lists the features supported by the server.