postfix常用命令介绍

5-07 2,969 views

*查看队列
postqueue -p
*删除队列邮件根据ID
postsuper -d MessageID
*根据发送者来删除队列邮件,替换 “info@otherdomain.com”就可以
mailq | tail +2 | awk ‘BEGIN { RS = “” }# $7=sender, $8=recipient1, $9=recipient2{ if ($7 == “info@otherdomain.com” && $9 == “”)print $1 }‘ | tr -d ‘*!’ | postsuper -d –
*根据收件人删除,替换you@yourdomain.com 就可以
mailq | tail +2 | awk ‘BEGIN { RS = “” }# $7=sender, $8=recipient1, $9=recipient2{ if ($8 == “you@yourdomain.com” && $9 == “”)print $1 }‘ | tr -d ‘*!’ | postsuper -d –
*根据发生服务器的hostname来删除,替换掉 senderhostname
mailq | grep senderhostname | awk ‘{ print $1} ‘| postsuper -d –
*如果当前的系统队列很长,负担很重,我们可以把队列里的邮件先hold
postsuper -h ALL

*当处理完后,再把队列移回来

postsuper -r ALL

postfix本身可以作为命令使用:

*启动postfix
postfix start

*停止postfix

postfix stop
*重新读取postfix配置文件

postfix reload
*立即投递队列中所有邮件(慎用)

postfix flush

*修复队列以及任何权限错误
postfix check

 

常用操作:
postqueue -p 列出队列里的所有邮件
postsuper -d ID 删除一封邮件
postsuper -d ALL 删除所有邮件
postsuper –h ID 保留邮件
postsuper -r ALL 重新排例
postcat -q ID   显示邮件内容
postqueue -f   清空邮件

测试邮件的命令:
测试邮件,可以用客户端,也可以使用命令行测试,这样更加直接。

*BASE64编码的用户名密码
我们需要把我们的登录帐号和密码一起编码
user:www@example.com
pass: iredmail
# perl -MMIME::Base64 -e ‘print encode_base64(“www@example.comwww@example.comiredmail”)’;
d3d3QGV4YW1wbGUuY29tAHd3d0BleGFtcGxlLmNvbQBpcmVkbWFpbA==

*SMTP 登录并发送邮件
# telnet localhost 25            #在服务器上telnet到本地,下面的是正常输出
Trying ::1…
Trying 127.0.0.1…
Connected to localhost.
Escape character is ‘^]’.
220 u910.example.com ESMTP iRedMail (Ubuntu)
ehlo example.com                   #握手
250-u910.example.com
250-PIPELINING
250-SIZE 15728640
250-ETRN
250-STARTTLS
250-AUTH PLAIN LOGIN
250-AUTH=PLAIN LOGIN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
auth plain d3d3QGV4YW1wbGUuY29tAHd3d0BleGFtcGxlLmNvbQBpcmVkbWFpbA==  # 输入base 64后的用户名和密码
235 2.7.0 Authentication successful
mail from:<www@example.com>         #使用 www@example.com 帐号对外发送邮件
250 2.1.0 Ok
rcpt to:<shake.chen@gmail.com>          #发送邮件到 shake.chen@gmail.com 这个邮箱
250 2.1.5 Ok
data                                                    #输入data命令后,下面就是邮件的内容
354 End data with <CR><LF>.<CR><LF>
to:shake.chen@gmail.com                    #这是邮件里显示的发送给谁。
from:www@example.com                     #那个帐号发送过来的
subject: test by telnet smtp                  #邮件的主题
test , just a test ,check the subject whetehr working.
.            #写完邮件后,输入一个点,回车,就表示邮件完成。
250 2.0.0 Ok: queued as B6B4820EC9
quit              #退出
221 2.0.0 Bye
Connection closed by foreign host.

*pop3连接
可以在远程使用命令行或者本地来测试pop3
# telnet localhost 110     #登录110端口
Trying ::1…
Trying 127.0.0.1…
Connected to localhost.
Escape character is ‘^]’.
+OK Dovecot ready.
user www@example.com    #输入登录的邮件帐号
+OK
pass iredmail          #帐号的密码,这里直接输入密码就可以
+OK Logged in.
list                           #查看邮箱里的邮件
+OK 4 messages:
1 1182
2 6195
3 1588
4 878
.
retr 1                  #显示第一封邮件内容
quit                     #退出
+OK Logging out.
Connection closed by foreign host.

引用来源 : http://www.ha97.com/4373.html

Linux使用lsyncd实现2个文件夹实时同步

官方文档: https://axkibe.github.io/lsyncd/download/ 1.安装 $ yum install lsyncd $ yum install rsync $ yum install libtermcap-devel ncurses-devel l...

阅读全文

firewall 防火墙常用命令

查看版本 $ firewall-cmd --version 0.4.3.3 help $ firewall-cmd --help 状态 $ firewall-cmd --state running 重载配置 $ firewall-cmd --reload 重新加载...

阅读全文

修改linux centos系统默认时区

方法一 先安装ntpdate: yum install -y ntpdate 再选择一个时间服务器来更新时间: ntpdate time.windows.com 恢复系统时间为utc时间 ln -sf /usr/share/zo...

阅读全文

欢迎留言