简体   繁体   中英

Cannot send mail from Net::Server::Mail::SMTP using Email::Simple::Sender

From within my sub that handles the DATA event:

my $email = Email::Simple->create(
    header => [
      To      => $recipient,
      From    => $sender,
      Subject => $subject,
    ],
    body => $body,
);
sendmail($email);

When I try to do a test, I telnet to the server get to the DATA and when I put in the . (which fires this event) I get this:

at /usr/local/share/perl5/Net/Server/Mail.pm line 351, <GEN1> line 6.
    Net::Server::Mail::callback('Net::Server::Mail::ESMTP=HASH(0x3a06288)', 'DATA', 'SCALAR(0x3ae0b58)') called at /usr/local/share/perl5/Net/Server/Mail.pm line 233
    Net::Server::Mail::make_event('Net::Server::Mail::ESMTP=HASH(0x3a06288)', 'name', 'DATA', 'arguments', 'ARRAY(0x3ae0df8)', 'success_reply', 'ARRAY(0x3ae0f90)') called at /usr/local/share/perl5/Net/Server/Mail/SMTP.pm line 644
    Net::Server::Mail::SMTP::data_finished('Net::Server::Mail::ESMTP=HASH(0x3a06288)', '') called at /usr/local/share/perl5/Net/Server/Mail/SMTP.pm line 618
    Net::Server::Mail::SMTP::data_part('Net::Server::Mail::ESMTP=HASH(0x3a06288)', '.\x{d}\x{a}') called at /usr/local/share/perl5/Net/Server/Mail.pm line 443
    Net::Server::Mail::tell_next_input_method('Net::Server::Mail::ESMTP=HASH(0x3a06288)', '.\x{d}\x{a}') called at /usr/local/share/perl5/Net/Server/Mail.pm line 516
    Net::Server::Mail::process('Net::Server::Mail::ESMTP=HASH(0x3a06288)') called at /path/to/mail_server.pl line 47

It works fine (except it does not send the email) if I remove the sendmail call.

At this point, I usually start reading the source code. See what's going on at line 351 of N::S::M, and then proceed from there.

Also, look at your mailer's logs. Maybe there something wrong when the program tries to deliver the mail - either locally, or direct tot he remote recipient.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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