output to STDERR seen in SMTP transaction?
Brought to you by:
pavcio
|
From: Albert C. <ac...@cy...> - 2008-11-12 23:27:20
|
Platform details:
Plesk 8.3 - qmail 1.0.6 with qmail-spp 0.41 (I believe, from the
dates in the patch)
Problem description:
In attempting to write my first plugin, I decided as a test to just
log the value of the environment variables listed in the documentation
by using perl's warn() statement, which sends its output to STDERR only.
However, when I attempted an SMTP transaction, I saw in the transaction
what I had attempted to log. Am I misreading the documentation, or doing
something incorrectly?
Any clue you can provide would be greatly appreciated. (Code and
output modified for hostnames and email addresses only to protect the
clueless.)
Output, Observed:
$ ./tester.pl
Net::SMTP>>> Net::SMTP(2.29)
Net::SMTP>>> Net::Cmd(2.26)
Net::SMTP>>> Exporter(5.58)
Net::SMTP>>> IO::Socket::INET(1.31)
Net::SMTP>>> IO::Socket(1.30)
Net::SMTP>>> IO::Handle(1.27)
Net::SMTP=GLOB(0x80c64d0)<<< 220 mail.example.com ESMTP
Net::SMTP=GLOB(0x80c64d0)>>> EHLO localhost.localdomain
Net::SMTP=GLOB(0x80c64d0)<<< 250-mail.example.com
Net::SMTP=GLOB(0x80c64d0)<<< 250-AUTH=LOGIN CRAM-MD5 PLAIN
Net::SMTP=GLOB(0x80c64d0)<<< 250-AUTH LOGIN CRAM-MD5 PLAIN
Net::SMTP=GLOB(0x80c64d0)<<< 250-STARTTLS
Net::SMTP=GLOB(0x80c64d0)<<< 250-PIPELINING
Net::SMTP=GLOB(0x80c64d0)<<< 250 8BITMIME
Net::SMTP=GLOB(0x80c64d0)>>> MAIL FROM:<te...@ex...>
Net::SMTP=GLOB(0x80c64d0)<<< 250 ok
Net::SMTP=GLOB(0x80c64d0)>>> RCPT TO:<te...@ex...>
Net::SMTP=GLOB(0x80c64d0)<<< SMTPHELOHOST = localhost.localdomain
Died at ./tester.pl line 38.
Output, Expected:
$ ./tester.pl
Net::SMTP>>> Net::SMTP(2.29)
Net::SMTP>>> Net::Cmd(2.26)
Net::SMTP>>> Exporter(5.58)
Net::SMTP>>> IO::Socket::INET(1.31)
Net::SMTP>>> IO::Socket(1.30)
Net::SMTP>>> IO::Handle(1.27)
Net::SMTP=GLOB(0x80c64d0)<<< 220 mail.example.com ESMTP
Net::SMTP=GLOB(0x80c64d0)>>> EHLO localhost.localdomain
Net::SMTP=GLOB(0x80c64d0)<<< 250-mail.example.com
Net::SMTP=GLOB(0x80c64d0)<<< 250-AUTH=LOGIN CRAM-MD5 PLAIN
Net::SMTP=GLOB(0x80c64d0)<<< 250-AUTH LOGIN CRAM-MD5 PLAIN
Net::SMTP=GLOB(0x80c64d0)<<< 250-STARTTLS
Net::SMTP=GLOB(0x80c64d0)<<< 250-PIPELINING
Net::SMTP=GLOB(0x80c64d0)<<< 250 8BITMIME
Net::SMTP=GLOB(0x80c64d0)>>> MAIL FROM:<te...@ex...>
Net::SMTP=GLOB(0x80c64d0)<<< 250 ok
Net::SMTP=GLOB(0x80c64d0)>>> RCPT TO:<te...@ex...>
Net::SMTP=GLOB(0x80c64d0)<<< 250 ok
Net::SMTP=GLOB(0x80c64d0)>>> QUIT
Net::SMTP=GLOB(0x80c64d0)<<< 221 mail.example.com
Code, control/smtpplugins:
[rcpt]
plugins/chkrcptto
plugins/test_plugin.pl
Code, plugins/test_plugin.pl:
#!/usr/bin/suidperl -T
#
# Script set 04555
#
use strict;
use warnings;
foreach my $k (
qw(SMTPHELOHOST SMTPMAILFROM SMTPRCPTTO SMTPRCPTCOUNT
SMTPRCPTCOUNTALL SMTPRCPTHOSTSOK SMTPAUTHUSER SMTPAUTHMETHOD)
)
{
warn sprintf qq{%s = %s\n}, $k,
defined( $ENV{$k} ) ? $ENV{$k} : q{not defined};
}
exit 0;
Code, tester.pl:
#!/usr/bin/perl
#
# Purpose: Allow consistent testing of SMTP transaction
#
use strict;
use warnings;
use Net::SMTP;
$| = 1;
my $recipient = q{te...@ex...};
my $sender = q{te...@ex...};
my $target_host = q{mail.example.com};
my $helo =
q{localhost.localdomain};
my $timeout = 30;
my $DEBUG = 1;
my $smtp = Net::SMTP->new(
$target_host,
Hello => $helo,
Timeout => $timeout,
Debug => $DEBUG,
) or die $!;
$smtp->mail($sender) or die $!;
$smtp->to($recipient) or die $!;
$smtp->quit() or die $!;
|