aboutsummaryrefslogtreecommitdiffstats
path: root/pullimap
diff options
context:
space:
mode:
authorGuilhem Moulin <guilhem@fripost.org>2016-03-08 23:13:43 +0100
committerGuilhem Moulin <guilhem@fripost.org>2016-03-08 23:13:43 +0100
commitec87e1965d758bc3af4403a3cf469c3297f8cb1a (patch)
tree64989e2ace4e84da226177cdc9a8e95bd5c2f5ef /pullimap
parentaecdd0c6657e3edb0482751efffdcafb96f2c2c5 (diff)
parent6bf9ee9a1e1c704490489f682dfe106f2c1ee46a (diff)
Merge branch 'master' into debian
Diffstat (limited to 'pullimap')
-rwxr-xr-xpullimap15
1 files changed, 8 insertions, 7 deletions
diff --git a/pullimap b/pullimap
index 0e31a90..c16d6ac 100755
--- a/pullimap
+++ b/pullimap
@@ -221,7 +221,7 @@ sub smtp_send(@) {
$CONF->{'logger-fd'} = \*STDERR if $CONFIG{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';
+ $config{keepalive} = 1 if defined $CONFIG{idle};
Net::IMAP::InterIMAP::->new( %config );
};
@@ -234,11 +234,11 @@ sub purge() {
return unless 1<$uidnext;
my $set = "1:".($uidnext-1);
- my $now = time;
- return if defined $LAST_PURGED and $now - $LAST_PURGED < 6*3600;
- $LAST_PURGED = $now;
-
unless ($days == 0) {
+ my $now = time;
+ return if defined $LAST_PURGED and $now - $LAST_PURGED < 6*3600; # purge every 6h
+ $LAST_PURGED = $now;
+
my @now = gmtime($now - $days*86400);
my @m = qw/Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec/; # RFC 3501's date-month
my $date = sprintf("%02d-%s-%04d", $now[3], $m[$now[4]], $now[5]+1900);
@@ -254,7 +254,8 @@ sub purge() {
# Use BODY.PEEK[] so if something gets wrong, unpulled messages
# won't be marked as \Seen in the mailbox
-my $ATTRS = "ENVELOPE INTERNALDATE BODY.PEEK[]";
+my $ATTRS = "ENVELOPE INTERNALDATE";
+$ATTRS .= " BODY.PEEK[]" unless $CONFIG{'no-delivery'};
# Pull new messages from IMAP and deliver them to SMTP, then update the
# statefile
@@ -265,7 +266,7 @@ sub pull(;$) {
# invariant: we're at pos 8 + 4*(1+$#ignore + 1+$#uids) in the statefile
$IMAP->pull_new_messages($ATTRS, sub($) {
my $mail = shift;
- return unless exists $mail->{RFC822}; # not for us
+ return unless exists $mail->{RFC822} or $CONFIG{'no-delivery'}; # not for us
my $uid = $mail->{UID};
my $from = first { defined $_ and @$_ } @{$mail->{ENVELOPE}}[2,3,4];