问题描述:

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:

Current Setting: |/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. 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 [email protected]

The following text was generated during the delivery attempt:

------ pipe to |/home/user/public_html/cgi-bin/links/email-in.cgi

generated by [email protected] ------

Content-type: text/html; charset=iso-8859-1

FOO BAR Action: failed Final-Recipient:

rfc822;|/home/user/public_html/cgi-bin/links/email-in.cgi Status:

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

If your script produces any output, even a blank line, the system will create a bounce message that contains that output.

相关阅读:
Top