命令行管理和测试posfix邮件系统
来源:互联网 发布:c和a的算法 编辑:程序博客网 时间:2024/05/21 11:19
命令行管理postfix队列
*查看队列
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
附常用操作:
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.com\0www\@example.com\0iredmail")';
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.
*查看队列
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 ALLpostfix本身可以作为命令使用:
*启动postfix
postfix start
*停止postfix
postfix stop
*重新读取postfix配置文件
postfix reload
*立即投递队列中所有邮件(慎用)
postfix flush
*修复队列以及任何权限错误
postfix check
参考文章 http://www.faqforge.com/linux/server/manage-the-postfix-mailqueue-with-postsuper-postqueue-und-mailq/
附常用操作:
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.com\0www\@example.com\0iredmail")';
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.
- 命令行管理和测试posfix邮件系统
- posfix 邮件系统安装完整版
- Postfix 邮件系统常用测试与管理命令
- qmail邮件系统(六)日志和管理
- qmail邮件系统(五)vpopmail和qmailadmin对用户的管理
- qmail邮件系统(六)qmail的日志和管理
- openstack 命令行管理十六 - 网络测试 (备忘)
- 打印管理和命令行说明
- 邮件系统
- 邮件系统
- 邮件系统
- 邮件系统
- 邮件系统
- 邮件系统
- 邮件系统
- 邮件系统
- 邮件系统
- 定制和维护邮件系统总结
- warning: do not list domain haha.com.cn in BOTH mydestination and virtual_mailbox_domains
- 项目管理工具-Jira
- QML与c++交互学习笔记(八) qt c++直接调用QML中的函数, 直接设置属性
- Joomla源代码解析(六) JDocument 类的几个常用的方法
- 透过 Linux 内核看无锁编程
- 命令行管理和测试posfix邮件系统
- System.Web.Mail 邮件正文显示图片
- windows hosts 文件读写小工具
- Quick3D 学习文档
- 大端小端网络字节顺序
- 项目管理工具-Trac
- Joomla源代码解析(七) JFactory 类
- 项目管理工具-Saas
- qml 学习