由于mailman前端没有提供管理员删特定邮件的功能,这对列表管理者来说无疑比较麻烦,看了下官方文档,发现唯一的方法就是通过ssh到服务器然后通过mailman预留的python工具在命令行里面删除,虽然比较麻烦,大概是为了安全考虑吧。
比如在swjtuosc_community中有一份特定的邮件违反了列表的规则(比如反党反国家,随意辱骂他人等,自己随意脑补),然后管理员决定要删除这份特定邮件,那么怎么做呢。
step 1-ssh到mailman的服务器
这个就不要我教了吧
step 2-找到swjtuosc_community邮件存档文件
该文档存档位于:/var/lib/mailman/archives/private/swjtuosc_community.mbox/swjtuosc_community.mbox
(For Ubuntu)
其他发行版的Linux自己找去吧
step 3-编辑该mbox文件
通过mail -f
命令打开该文件,找到需要删除的特定邮件
$mailman -f swjtuosc_community.mbox
Heirloom mailx version 12.5 6/20/10. Type ? for help.
"swjtuosc_community.mbox": 24 messages 24 unread
>U 1 Li Jonathan Mon Mar 16 15:06 157/10541 [swjtuosc_community] [OT]我们为什么创建西南交通大学开源社区邮件列表
U 2 xiexiaoyang Fri Mar 20 05:14 281/19792 [swjtuosc_community] flask-sqlalchemy 连接 Debian 报错
U 3 xiexiaoyang Fri Mar 20 09:00 308/21839 Re: [swjtuosc_community] flask-sqlalchemy 连接 Debian 报错
U 4 Ho Lee Tue Mar 24 06:50 65/3456 [swjtuosc_community] [OT]我年前提交了份“实验楼”网站的校园大使申请
...
U 23 薛铭乾 Sat Apr 4 12:31 86/5009 Re: [swjtuosc_community] re
U 24 Ho Lee Sat Apr 4 15:28 159/10645 Re: [swjtuosc_community] re
?
可以看到每一封邮件都有一个id,删除的时候通过指定id来删除,但是怎么删除邮件呢,没关系,mail命令很用户友好哦,不懂的就输入?
吧,然后我们就得到了mail命令的详细用法了。
mail commands
type <message list> type messages
next goto and type next message
from <message list> give head lines of messages
headers print out active message headers
delete <message list> delete messages
undelete <message list> undelete messages
save <message list> folder append messages to folder and mark as saved
copy <message list> folder append messages to folder without marking them
write <message list> file append message texts to file, save attachments
preserve <message list> keep incoming messages in mailbox even if saved
Reply <message list> reply to message senders
reply <message list> reply to message senders and all recipients
mail addresses mail to specific recipients
file folder change to another folder
quit quit and apply changes to folder
xit quit and discard changes made to folder
! shell escape
cd <directory> chdir to directory or home if none given
list list names of all available commands
A <message list> consists of integers, ranges of same, or other criteria
separated by spaces. If omitted, mail uses the last message typed.
?
可由上面的帮助看到,删除邮件通过delete <message list>
来实现,<message list>可以有多个id,通过空格分割。
ok,比如我要删除编号为4的Ho Lee发的那一封邮件,就可以用delete 4
搞定啦。
输入quit
退出mail命令。
step 4-重建历史归档
直接删除邮件还不行哦,需要重新归档索引下才生效呢,命令如下: /var/lib/mailman/bin/arch --wipe swjtuosc_community
deals done!
参考: