lar*_*sks 17
formail,procmail 的一部分(可能已经在您的系统上可用)可以接收一个邮箱,将其拆分为消息,然后在每个消息上运行一个命令。从手册页:
-s The input will be split up into separate mail messages, and piped
into a program one by one (a new program is started for every
part). -s has to be the last option specified, the first argument
following it is expected to be the name of a program, any other
arguments will be passed along to it. If you omit the program,
then formail will simply concatenate the split mails on stdout
again. See FILENO.
Run Code Online (Sandbox Code Playgroud)
所以你可以做我认为你想做的事情:
formail -s /usr/sbin/sendmail -oi -t < /var/mail/root
Run Code Online (Sandbox Code Playgroud)
小智 0
/var/spool/mail/xxx unix 邮箱文件是简单的文本文件,其中邮件消息按顺序保存。每封邮件均以“发件人”行(这不是邮件的一部分)开头,其中包含发件人和接收日期,然后您将获得邮件标头,然后是邮件正文。
基本上,您可以循环检测此类 From 行并提取每条消息,然后使用 python smtp 模块或 cpan 中的 perl Net::SMTP 模块等工具发送它们。
如果目标是另一个本地邮箱,您只需将邮件(包括“发件人”行)附加到其中即可。如果您不关心获取真正针对 root 的邮件,您甚至可以将整个 root 邮箱附加到另一个邮箱。
我应该有一些脚本可以做到这一点,如果您愿意的话,我会发布示例。
问题可能是获取邮件的真正目标,因为如果它们以 root 邮箱结束,那么它们可能从一开始就以 root 为目标?
| 归档时间: |
|
| 查看次数: |
6080 次 |
| 最近记录: |