有没有比 postcat 更好的工具来查看 postfix 邮件队列文件?

发布于 2024-08-31 08:10:32 字数 1021 浏览 8 评论 0原文

因此,今天早上我接到一个电话,称一位客户需要查看我们的辅助邮件服务器中等待发送的电子邮件。他们的主服务器链接已经(仍然)关闭了两天,他们需要查看他们的电子邮件。

因此,我编写了一个快速 Perl 脚本,结合使用 mailq 和 postcat 将其地址的每封电子邮件转储到单独的文件中,打包并发送出去。我知道代码很糟糕,但是很紧急。

我的解决方案工作正常,因为它至少提供了一个原始视图,但我想今晚如果我有一个解决方案,可以提供他们的电子邮件附件,也许还可以删除一些“垃圾”标题文本,那就太好了。大多数重要的电子邮件似乎都附有 PDF 或类似文件。

我一直在环顾四周,但我能看到的查看队列文件的唯一方法是 postcat 命令,而且我真的不想编写自己的解析器 - 所以我想知道你们中是否有人已经这样做了,或者知道有更好的命令使用吗?

这是我当前解决方案的代码:

#!/usr/bin/perl

$qCmd="mailq | grep -B 2 \"someemailaddress@isp\" | cut -d \" \" -f 1";

@data = split(/\n/, `$qCmd`);
$i = 0;

foreach $line (@data)
{
    $i++;

    $remainder = $i % 2;
    if ($remainder == 0)
    {
            next;
    }

    if ($line =~ /\(/ || $line =~ /\n/ || $line eq "")
    {
        next;
    }
    print "Processing: " . $line . "\n";
    `postcat -q $line > $line.email.txt`;
    $subject=`cat $line.email.txt | grep "Subject:"`;
    #print "SUB" . $subject;
    #`cat $line.email.txt > \"$subject.$line.email.txt\"`;
}

任何建议表示赞赏。

So I got a call early this morning about a client needing to see what email they have waiting to be delivered sitting in our secondary mail server. Their link for the main server had (still is) been down for two days and they needed to see their email.

So I wrote up a quick Perl script to use mailq in combination with postcat to dump each email for their address into separate files, tar'd it up and sent it off. Horrible code, I know, but it was urgent.

My solution works OK in that it at least gives a raw view, but I thought tonight it would be nice if I had a solution where I could provide their email attachments and maybe remove some "garbage" header text as well. Most of the important emails seem to have a PDF or similar attached.

I've been looking around but the only method of viewing queue files I can see is the postcat command, and I really don't want to write my own parser - so I was wondering if any of you have already done so, or know of a better command to use?

Here's the code for my current solution:

#!/usr/bin/perl

$qCmd="mailq | grep -B 2 \"someemailaddress@isp\" | cut -d \" \" -f 1";

@data = split(/\n/, `$qCmd`);
$i = 0;

foreach $line (@data)
{
    $i++;

    $remainder = $i % 2;
    if ($remainder == 0)
    {
            next;
    }

    if ($line =~ /\(/ || $line =~ /\n/ || $line eq "")
    {
        next;
    }
    print "Processing: " . $line . "\n";
    `postcat -q $line > $line.email.txt`;
    $subject=`cat $line.email.txt | grep "Subject:"`;
    #print "SUB" . $subject;
    #`cat $line.email.txt > \"$subject.$line.email.txt\"`;
}

Any advice appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我三岁 2024-09-07 08:10:32

您可能会发现 Postfix::Parse::Mailq 模块的使用此处,以及 pfcat 脚本。

You may find the Postfix::Parse::Mailq module of use here, as well as the pfcat script.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文