diff options
author | Guilhem Moulin <guilhem@fripost.org> | 2016-03-07 17:32:29 +0100 |
---|---|---|
committer | Guilhem Moulin <guilhem@fripost.org> | 2016-03-07 17:32:29 +0100 |
commit | 67f7ae7c82263dc3acad7f6b4df586f94f3b5e15 (patch) | |
tree | 756ef9a00496e35703810637777177e39371bcfe | |
parent | 247cc63d7710e1907b114a75125c27de946415aa (diff) |
wibble
-rw-r--r-- | lib/Net/IMAP/InterIMAP.pm | 2 | ||||
-rwxr-xr-x | pullimap | 16 |
2 files changed, 10 insertions, 8 deletions
diff --git a/lib/Net/IMAP/InterIMAP.pm b/lib/Net/IMAP/InterIMAP.pm index 01fb6a9..be62a9d 100644 --- a/lib/Net/IMAP/InterIMAP.pm +++ b/lib/Net/IMAP/InterIMAP.pm @@ -2335,7 +2335,7 @@ sub _resp($$;$$$) { } } elsif (s/\A\+// and ($_ eq '' or s/\A //)) { - # microsoft's IMAP server violates RFC 3501 by skipping the trailing ' ' for empty resp-text + # Microsoft Exchange Server 2010 violates RFC 3501 by skipping the trailing ' ' for empty resp-text if (defined $callback and $cmd eq 'AUTHENTICATE') { my $x = $callback->($_); $self->_cmd_extend(\$x); @@ -1,7 +1,7 @@ #!/usr/bin/perl -T #---------------------------------------------------------------------- -# Pull mails from an IMAP mailbox and deliver them to an SMTP session +# Pull mails from an IMAP mailbox and deliver them to a SMTP session # Copyright © 2016 Guilhem Moulin <guilhem@fripost.org> # # This program is free software: you can redistribute it and/or modify @@ -59,10 +59,10 @@ my $CONF = read_config( delete $CONFIG{config} // $NAME, , [$ARGV[0]] , statefile => qr/\A(\P{Control}+)\z/ , mailbox => qr/\A([\x01-\x7F]+)\z/ - , 'deliver-method' => qr/\A((?:[ls]mtp:)?\[.*\](?::\d+)?)\z/ + , 'deliver-method' => qr/\A([ls]mtp:\[.*\]:\d+)\z/ , 'deliver-ehlo' => qr/\A(\P{Control}+)\z/ , 'deliver-rcpt' => qr/\A(\P{Control}+)\z/ - , 'purge-after' => qr/\A(\d+)d\z/ + , 'purge-after' => qr/\A(\d+)\z/ )->{$ARGV[0]}; my ($MAILBOX, $STATE); @@ -122,12 +122,12 @@ sub sendmail($$) { unless (defined $SMTP) { # 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'} // 'smtp:[127.0.0.1]:10024', 25); + 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; $ehlo .= ' '. ($CONF->{'deliver-ehlo'} // 'localhost.localdomain'); - $port = $1 if $addr =~ s/:(\d+)$//; + my $port = $addr =~ s/:(\d+)$// ? $1 : die; $addr =~ s/^\[(.*)\]$/$1/ or die; $fam = PF_INET6 if $addr =~ /:/; $addr = Socket::inet_pton($fam, $addr) // die "Invalid address $addr\n"; @@ -226,7 +226,6 @@ my $IMAP = Net::IMAP::InterIMAP::->new( %$CONF, %CONFIG{qw/quiet debug/} ); my $LAST_PURGED; sub purge() { my $days = $CONF->{'purge-after'} // return; - $days =~ s/d$//; my ($uidnext) = $IMAP->get_cache('UIDNEXT'); return unless 1<$uidnext; my $set = "1:".($uidnext-1); @@ -319,7 +318,10 @@ do { pull($ignore); purge(); }; -exit 0 unless defined $CONFIG{idle}; +unless (defined $CONFIG{idle}) { + $IMAP->logout(); + exit 0; +} $CONFIG{idle} = 1740 if defined $CONFIG{idle} and $CONFIG{idle} == 0; # 29 mins while(1) { |