Kyle’s Reference Links

Contents External Links Friendly Links Marvin Links

SMTP -- an example

What you type is in bold type. You can get an SMTP connection by telnetting to port 25.

220 memoryhole.net ESMTP
helo friend
250 memoryhole.net
mail from: st.claus@north.pole
250 ok
rcpt to: foo@bar.com
250 ok
data
354 go ahead
content goes here
.

250 ok 1047595906 qp 9888
quit
221 memoryhole.net

Easy.

SMTP AUTH — an example

SMTP AUTH is more interesting. For the following examples, presume that the username is foo and the password is bar.

For AUTH PLAIN, the conversation looks something like this:

AUTH PLAIN
334
AGZvbwBiYXI=
235 2.0.0 OK Authenticated

That garbage in the middle is the base64-encoded string generated like so: printf "\0foo\0bar" | openssl base64

For AUTH LOGIN, the conversation looks something like this:

AUTH LOGIN
334 VXN1cm5hbWU6
Zm9v
334 UGFzc3dvcmQ6
YmFy
235 2.0.0 OK Authenticated

Again, that's just all base64-encoded, only rather than having nulls first like in the PLAIN example, LOGIN expects just the characters, without nulls, generated like so: printf 'foo' | openssl base64. Decoded, the above conversation looks like this:

AUTH LOGIN
334 Username:
foo
334 Password:
bar
235 2.0.0 OK Authenticated

An SSL connection can be made with the openssl program, like so:

openssl s_client -starttls smtp -connect host:port
Valid XHTML 1.0 Strict! Valid CSS! Lovingly handcrafted with Vim