【问题标题】:Postfix bounce message with error info from script带有来自脚本的错误信息的 Postfix 退回消息
【发布时间】:2014-06-02 21:23:33
【问题描述】:

我想在后缀中创建退回消息,该消息将显示来自我的过滤器脚本的错误信息。我发现如果我从像 1 这样的脚本返回错误代码,我会看到所有数据都打印到标准输出,但我也会看到有关脚本文件的信息。例如:

This is the mail system at host mail.somesys.pl.

I'm sorry to have to inform you that your message could not be delivered to one or more recipients. It's attached below.

For further assistance, please send mail to postmaster.

If you do so, please include this problem report. You can delete your own text from the attached returned message.

                   The mail system

<user01@mail.somesys.pl>: Command died with status 1:
    "/opt/SmtpReceiver/SmtpReceiverHandler.py". Command output: NO FILES OR BAD
    CREDENTIALS

而我只想拥有这样的东西:

...
                   The mail system

NO FILES OR BAD CREDENTIALS

我的 postfix master.cf 配置:

smtp      inet  n       -       n       -       -       smtpd
        -o content_filter=myhook:dummy
...
myhook unix - n n - - pipe
  flags=F user=user01 argv=/opt/SmtpReceiver/SmtpReceiverHandler.py ${sender} ${size} ${recipient}

还有python脚本:

if __name__=='__main__':

    try:
        app = SmtpReceiverHandler();
        app.run();
    except Exception, e:
        print e;
        sys.exit(1);

【问题讨论】:

    标签: python postfix-mta


    【解决方案1】:

    您可以在main.cf 中指定bouce_template_file

    #/etc/postfix/main.cf
    bounce_template_file = /etc/postfix/bounce.cf
    
    #/etc/postfix/bounce.cf
    failure_template = <<EOF
    Charset: us-ascii
    From: MAILER-DAEMON (Mail Delivery System)
    Subject: Undelivered Mail Returned to Sender
    Postmaster-Subject: Postmaster Copy: Undelivered Mail
    
        The mail system
    EOF
    

    参考:Postfix docs

    【讨论】:

    • 谢谢,但我不想更改默认模板(暂时)。我想要的是在退回消息的末尾添加,从我的过滤器脚本输出,但没有关于文件的信息。
    • 我不认为这是可能的。
    猜你喜欢
    • 2011-01-19
    • 1970-01-01
    • 2016-02-03
    • 2021-07-30
    • 1970-01-01
    • 2013-08-05
    • 1970-01-01
    • 2022-12-20
    • 1970-01-01
    相关资源
    最近更新 更多