pop3&&IMAP4 login

登录pop3检查邮件数量
#!/bin/bash mailserver=pop3.test.com user='username' password='pass' exec 9<>/dev/tcp/$mailserver/110 read -r temp <&9 echo "$temp" echo "user $user" >&9 read -r temp <&9 echo "$temp" echo "pass $password" >&9 read -r temp <&9 echo "$temp" echo "stat" >&9 read -r temp <&9 echo "$temp"

 

clean.sh 删除邮件
#!/bin/sh username="test@pop3.test.com"; password="password"; MAX_MESS=$1 [ $# -eq 0 ] && exit 1 || : sleep 2 echo USER $username sleep 1 echo PASS $password sleep 2 for (( j = 1 ; j <= $MAX_MESS; j++ )) do echo DELE $j sleep 1 done echo QUIT
删除邮件

$ ./clean.pop3 2500 | telnet pop3.test.com 110
#!/bin/bash
# Wed Jun 16 16:04:19 EDT 2004
# NAME: p1
# Copyright 2004, Chris F.A. Johnson
# Released under the terms of the GNU General Public License

CR=$'\r'  ## carriage return; for removal of

## connect to POP3 server on local machine, port 110
exec 3<>/dev/tcp/127.0.0.1/110

## get response from server
read ok line <&3

## check that it succeeded
[ "${ok%$CR}" != "+OK" ] && exit 5

## send user name, get response and check that it succeeded
echo user poppy >&3
read ok line <&3
[ "${ok%$CR}" != "+OK" ] && exit 5

## send password, get response and check that it succeeded
echo pass pop3test >&3
read ok line <&3
[ "${ok%$CR}" != "+OK" ] && exit 5

## get number of messages
echo stat >&3
read ok num x <&3

## display number of messages
echo $num messages

## close connection
echo quit >>&3

 

[anonymous@localhost ~]>>nc imap.mailserver.com 143
* OK [CAPABILITY IMAP4 IMAP4rev1 IDLE PUSHSERVICE ID UIDPLUS AUTH=LOGIN NAMESPACE] Mail IMAP4Server ready
C1 LOGIN user@mailserver.com password
C1 OK Success login ok

 

 

posted @ 2013-06-01 16:10  sunsweet  阅读(456)  评论(0编辑  收藏  举报