diff options
Diffstat (limited to 'pullimap')
-rwxr-xr-x | pullimap | 20 |
1 files changed, 4 insertions, 16 deletions
@@ -64,7 +64,7 @@ my $CONF = read_config( delete $CONFIG{config} // $NAME, , 'deliver-rcpt' => qr/\A(\P{Control}+)\z/ )->{$ARGV[0]}; -my ($MAILBOX, $STATE, $LOGGER_FD); +my ($MAILBOX, $STATE); do { $MAILBOX = $CONF->{mailbox} // 'INBOX'; @@ -86,19 +86,6 @@ do { fcntl($STATE, F_SETFL, $flags | FD_CLOEXEC) or die "fcntl F_SETFL: $!"; flock($STATE, LOCK_EX) or die "Can't flock $statefile: $!"; - - - if (defined (my $logfile = $CONF->{logfile})) { - require 'POSIX.pm'; - require 'Time/HiRes.pm'; - open $LOGGER_FD, '>>', $logfile or die "Can't open $logfile: $!\n"; - $LOGGER_FD->autoflush(1); - my $flags = fcntl($LOGGER_FD, F_GETFL, 0) or die "fcntl F_GETFL: $!"; - fcntl($LOGGER_FD, F_SETFL, $flags | FD_CLOEXEC) or die "fcntl F_SETFL: $!"; - } - elsif ($CONFIG{debug}) { - $LOGGER_FD = \*STDERR; - } }; @@ -230,11 +217,12 @@ sub smtp_send(@) { # Initialize the cache from the statefile, then pull new messages from # the remote mailbox # -my $IMAP = Net::IMAP::InterIMAP::->new( %$CONF, %CONFIG{qw/quiet debug/}, 'logger-fd' => $LOGGER_FD ); +$CONF->{'logger-fd'} = \*STDERR if $CONFIG{debug}; +my $IMAP = Net::IMAP::InterIMAP::->new( %$CONF, %CONFIG{qw/quiet debug/} ); # Use BODY.PEEK[] so if something gets wrong, unpulled messages # won't be marked as \Seen in the mailbox -my $ATTRS = join ' ', qw/ENVELOPE INTERNALDATE BODY.PEEK[]/; +my $ATTRS = "ENVELOPE INTERNALDATE BODY.PEEK[]"; # Pull new messages from IMAP and deliver them to SMTP, then update the # statefile |