aboutsummaryrefslogtreecommitdiffstats
path: root/pullimap
diff options
context:
space:
mode:
authorGuilhem Moulin <guilhem@fripost.org>2016-03-05 19:36:20 +0100
committerGuilhem Moulin <guilhem@fripost.org>2016-03-05 19:36:26 +0100
commit0c21fadd7683629c50d1068106b17e9ac1addc62 (patch)
tree26f2dbdba0a68f1e580b8cba182dcfc7b5ae1906 /pullimap
parente51c8899d67e5d86a868e1adced55a6c72113daa (diff)
Terminate the SMTP transmission channel gracefully.
Diffstat (limited to 'pullimap')
-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;