Subject: | Can't call method "reply" on unblessed reference |
On two debian systems both stable and unstable, with perl 5.10.0 and
5.10.1, the attached script dies with an error message:
Can't call method "reply" on unblessed reference at /usr/local/share/
perl/5.10.0/AnyEvent/SMTP/Server.pm line 188.
from a simple message:
`cat telnet.txt | nc localhost 25251`
telnet.txt contains:
HELO client.example.com
MAIL from: <sender@example.com>
RCPT to: <recipient@example.com>
DATA
From: sender@example.com
To: recipient@example.com
Subject: Test message
This is a test message.
.
QUIT
if the email processing function doesnt call an undefined function, the
program will not crash. however, i have another complex email processing
script, without calling any undefined functions, and it crashes on every
email with the same unblessed reference error.
Subject: | AnyEvent-SMTP-Server-debug.pl |
#!/usr/bin/perl -w
use strict;
use AnyEvent::SMTP::Server;
my $server_port = 25251;
my $server = AnyEvent::SMTP::Server->new(
port => $server_port
);
$server->reg_cb(
client => sub {
my ($s,$con) = @_;
warn "Client from $con->{host}:$con->{port} connected\n";
},
disconnect => sub {
my ($s,$con) = @_;
warn "Client from $con->{host}:$con->{port} gone\n";
},
mail => sub {
my ($s,$mail) = @_;
warn "Received mail from $mail->{from} to @{$mail->{to}}\n";
&process_message ($mail->{data} );
},
);
$server->start;
AnyEvent->condvar->recv;
sub process_message {
my $email = shift;
my $mailbox = shift ;
print &jadsuigflsgs($email);
}