Email fun, qmail pop3 suckage and netcat pop3 mail testing.

I recieved this in my mail today:

Your hosting account with [deleted] for [deleted].com has expired on 2004-02-03.

I got a similar one for a secondary domain. Aside from being 11 months early… come on, guys! ;)

In other news, qmail-pop3 is horrid. It can’t handle streamlining. What this means is you can’t just arbitrarily connect to a port, send it data, and expect it back. No. If you send qmail-pop3 too many queries, it’ll choke, then eventually just give -ERR.

This is annoying as all heck. I wanted to put a single-line POP3 command for everyone to use to just check their email. Yes, I am aware of the security implications involved, I just like giving little tricks here and there. ;)

Anyway, this is larger than it should be, mostly due to the fact that we need to allow an arbitrary wait time for qmail-pop3 to come to terms with itself, wake up, then get around to chewing through our mailspool.

I’ve elected to use printf here, as I have easier control of the line feed (\n) than with echo. ‘nc’ is the common UNIX ‘netcat’ utility. Of course, you should change ‘MYUSERNAME’, ‘MYPASSWORD’, and ‘mail.myhost.com’ for your needs.

%(printf “USER MYUSERNAME\nPASS MYPASSWORD\n”; sleep 1s; printf “STAT\n”; sleep 1s; printf “QUIT\n”) | nc -w2 o mail.myhost.com 110 | grep ‘OK [0-9]’ | awk ’{ print “You have”,$2,”messages.”}’
You have 8 messages.
%

This is a bit annoying and is quite a bit to type, so you could always make a macro out of it.

Here’s one way how to do it with zsh:

mailchk () { (printf “USER $2\nPASS $3\n”; sleep 1s; printf “STAT\n”; sleep 1s; printf “QUIT\n”) | nc -w2 mail.myhost.com 110 | grep ’+OK [0-9]’ |awk ’{ print “You have”,$2,”messages.” }’ }

Then, at the zsh prompt, you could type ‘mailchk MYNAME MYPASS’ to retrieve your mail. More than likely, you won’t want to do this, or put your passwords in your macro – for several reasons!