Also, if you just want to check how many messages there are, you can use this code instead:
usage: /checkmail <server> <port> <username> <password>
alias checkmail {
;1=server 2=port 3=username 4=password
;----------
set %chkmail.ADDR $1
set %chkmail.PORT $2
set %chkmail.USER $3
set %chkmail.PASS $4
;----------
set %chkmail.state 1
if ($sock(checkmail)) sockclose checkmail
sockopen checkmail %chkmail.ADDR %chkmail.PORT
}
on *:SOCKREAD:checkmail:{
var %s
sockread %s
tokenize 32 %s
; echo -s > $1-
if (OK isin $1) {
if (%chkmail.state == 1) {
echo 3 -a USER
sockwrite -n $sockname USER %chkmail.USER
}
elseif (%chkmail.state == 2) {
echo 3 -a PASS
sockwrite -n $sockname PASS %chkmail.PASS
}
elseif (%chkmail.state == 3) {
echo 3 -a STAT
sockwrite -n $sockname STAT
}
elseif (%chkmail.state == 4) {
[color:red];;; Number of messages is stored in $2 at this point only[/color]
echo 12 -a $2 $iif($2 == 1,message,messages)
echo 3 -a QUIT
sockwrite -n $sockname QUIT
}
elseif (%chkmail.state == 5) {
echo 3 -a DONE
sockclose $sockname
unset %chkmail.*
}
elseif (%chkmail.state < 1) {
echo 4 -a DONE
sockclose $sockname
unset %chkmail.*
}
else {
echo 4 -a Incompatible response at state %chkmail.state
echo 4 -a Error: $1-
sockwrite -n $sockname QUIT
set %chkmail.state -1
}
inc %chkmail.state
}
else {
echo 4 -a Unknown response at state %chkmail.state
echo 4 -a Error: $1-
sockwrite -n $sockname QUIT
set %chkmail.state -1
}
}
-genius_at_work