aboutsummaryrefslogtreecommitdiffstats
path: root/pullimap
diff options
context:
space:
mode:
Diffstat (limited to 'pullimap')
-rwxr-xr-xpullimap10
1 files changed, 7 insertions, 3 deletions
diff --git a/pullimap b/pullimap
index 27226d2..0e31a90 100755
--- a/pullimap
+++ b/pullimap
@@ -124,7 +124,7 @@ sub sendmail($$) {
# the connection due to a timeout (RFC 5321 section 4.5.3.2)
my ($fam, $addr) = (PF_INET, $CONF->{'deliver-method'} // 'smtp:[127.0.0.1]:25');
$addr =~ s/^([ls]mtp):// or die;
- my $ehlo = $1 eq 'lmtp' ? 'LHO' : $1 eq 'smtp' ? 'EHLO' : die;
+ my $ehlo = $1 eq 'lmtp' ? 'LHLO' : $1 eq 'smtp' ? 'EHLO' : die;
$ehlo .= ' '. ($CONF->{'deliver-ehlo'} // 'localhost.localdomain');
my $port = $addr =~ s/:(\d+)$// ? $1 : die;
@@ -219,7 +219,11 @@ sub smtp_send(@) {
# the remote mailbox
#
$CONF->{'logger-fd'} = \*STDERR if $CONFIG{debug};
-my $IMAP = Net::IMAP::InterIMAP::->new( %$CONF, %CONFIG{qw/quiet debug/} );
+my $IMAP = do {
+ my %config = (%$CONF, %CONFIG{qw/quiet debug/}, name => $ARGV[0]);
+ $config{keepalive} = 1 if defined $CONFIG{idle} and $config{type} ne 'tunnel';
+ Net::IMAP::InterIMAP::->new( %config );
+};
# Remove messages with UID < UIDNEXT and INTERNALDATE at most
# $CONF->{'purge-after'} days ago.
@@ -266,7 +270,7 @@ sub pull(;$) {
my $uid = $mail->{UID};
my $from = first { defined $_ and @$_ } @{$mail->{ENVELOPE}}[2,3,4];
$from = (defined $from and @$from) ? $from->[0]->[2].'@'.$from->[0]->[3] : '';
- print STDERR "($MAILBOX): UID $uid from <$from> ($mail->{INTERNALDATE})\n" unless $CONFIG{quiet};
+ $IMAP->log("UID $uid from <$from> ($mail->{INTERNALDATE})") unless $CONFIG{quiet};
sendmail($from, $mail->{RFC822}) unless $CONFIG{'no-delivery'};