简体   繁体   English

将电子邮件发送到Perl脚本,但总是返回错误消息

[英]Piping email to Perl script, but always gives back error message

I'm trying to figure out how to get this email piping to work in a script I'm doing. 我正在尝试弄清楚如何使此电子邮件管道在我正在执行的脚本中工作。 In CPanel, I have it setup to forward to: 在CPanel中,我将其设置为转发至:

Current Setting: |/home/user/public_html/cgi-bin/links/email-in.cgi 当前设置:| /home/user/public_html/cgi-bin/links/email-in.cgi

The script is really simple: 该脚本非常简单:

#!/usr/local/bin/perl

use strict;
use lib '/home/user/public_html/cgi-bin/links/admin';
use Links qw/$DB $IN $CFG/;
use CGI::Carp qw(fatalsToBrowser);
use Links;

Links::init('/home/user/public_html/cgi-bin/links/admin');

open (STDERR, ">>/home/user/public_html/cgi-bin/links/mail.log") || die $!;

my $message;
while (<STDIN>) {
    $message .= $_;
}

print STDERR qq|$message\n\n|;

close (STDERR);

print $IN->header;
print "FOO BAR";

Then sending a test email to that address, I correctly see the value of <STDIN> in email.log. 然后将测试电子邮件发送到该地址,我可以在email.log中正确看到<STDIN>的值。 However, a minute or so later, I get this email bounced back: 但是,大约一分钟后,我收到了该电子邮件的退回通知:

This message was created automatically by mail delivery software. 该消息是由邮件传递软件自动创建的。

A message that you sent could not be delivered to one or more of its recipients. 您发送的邮件无法传递给一个或多个收件人。 This is a permanent error. 这是一个永久性错误。 The following address(es) failed: 以下地址失败:

pipe to |/home/user/public_html/cgi-bin/links/email-in.cgi generated by foo@resa.site.org 管道到foo@resa.site.org生成的| /home/user/public_html/cgi-bin/links/email-in.cgi

The following text was generated during the delivery attempt: 尝试交付期间生成了以下文本:

------ pipe to |/home/user/public_html/cgi-bin/links/email-in.cgi generated by foo@resa.site.org ------ ------通过foo@resa.site.org生成的| /home/user/public_html/cgi-bin/links/email-in.cgi管道------

Content-type: text/html; 内容类型:text / html; charset=iso-8859-1 字符集= iso-8859-1

FOO BAR Action: failed Final-Recipient: rfc822;|/home/user/public_html/cgi-bin/links/email-in.cgi Status: 5.0.0 FOO BAR操作:最终收件人失败:rfc822; | /home/user/public_html/cgi-bin/links/email-in.cgi状态:5.0.0

I'm a bit confused as to why its doing that. 我对为什么要这样做感到有些困惑。 Do I need to return a specific header, or something like that? 我需要返回特定的标头,还是类似的东西? (to tell the email program that its been properly processed) (告诉电子邮件程序已正确处理)

Eugh, I knew this would happen! 恩,我知道这会发生! Literally as soon as I posted, I found the answer here: 从字面上看,我一经发布就在这里找到了答案:

https://confluence2.cpanel.net/display/ALD/Forwarders#Forwarders-PipetoaProgram https://confluence2.cpanel.net/display/ALD/Forwarders#Forwarders-PipetoaProgram

If your script produces any output, even a blank line, the system will create a bounce message that contains that output. 如果您的脚本产生了任何输出,甚至是空行,则系统将创建包含该输出的退回消息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM