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

 

 

转载于:https://www.cnblogs.com/sunsweet/archive/2013/06/01/3112571.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值