Subject: | Email::Send::SMTP doesn't always finish SMTP transaction properly |
Date: | Fri, 2 Jan 2009 13:44:30 +0100 |
To: | bug-Email-Send [...] rt.cpan.org |
From: | Patrick <pet [...] painfullscratch.nl> |
This is a follow up on https://bugs.launchpad.net/bugs/228679
Email::Send::SMTP doesn't always finish SMTP transaction properly.
(The same seems to apply for the current dev-version of Email::Sender
as well).
Email::Send::DESTROY sends the SMTP QUIT when the object gets out of
scope. However, there are certain scenarios in which the transaction
could already be closed by the SMTP server, due to a connection
timeout. Example:
=begin of example=
# some code here
my $sender = Email::Send->new({mailer => 'SMTP'});
$sender->mailer_args([Host=> 'smtp.example.com']);
$sender->send($message);
# some other code that could take more than a couple of seconds
# ... meanwhile, the SMTP server's transaction timeout is passed
# etc etc
=end of example=
=begin quote from RFC 2821 (http://www.ietf.org/rfc/rfc2821.txt)=
The last command in a session MUST be the QUIT command. The QUIT
command cannot be used at any other time in a session, but SHOULD be
used by the client SMTP to request connection closure, even when no
session opening command was sent and accepted.
=end quote from RFC 2821 (http://www.ietf.org/rfc/rfc2821.txt)=
Maybe it's better to send the QUIT right after the send() method is
issued. Another option could be to keep the connection open (using
NOOP) in some way until the object gets out of scope.