aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xpullimap7
1 files changed, 6 insertions, 1 deletions
diff --git a/pullimap b/pullimap
index 2c9b45d..40f7f6f 100755
--- a/pullimap
+++ b/pullimap
@@ -127,7 +127,8 @@ my ($SMTP, $SMTP_PIPELINING);
sub sendmail($$) {
my ($from, $rfc822) = @_;
unless (defined $SMTP) {
- # XXX we can be logged out while connected, so we need to be able to reconnect
+ # TODO we need to be able to reconnect when the server closes
+ # the connection due to a timeout (RFC 5321 section 4.5.3.2)
my ($fam, $addr, $port) = (PF_INET, $CONF->{'deliver-method'}, 25);
$addr =~ s/^([ls]mtp):// or die;
my $ehlo = $1 eq 'lmtp' ? 'LHO' : $1 eq 'smtp' ? 'EHLO' : die;
@@ -252,6 +253,10 @@ sub pull(;$) {
writeUID($uid);
}, @$ignore);
+ # terminate the transmission channel gracefully, cf RFC 5321 section 4.5.3.2
+ smtp_send('QUIT' => '221') if defined $SMTP;
+ undef $SMTP;
+
# now that everything has been deliverd, mark @ignore and @uid as \Seen
$IMAP->silent_store(compact_set(@$ignore, @uid), '+', '\Seen') if @$ignore or @uid;