my ($from) = grep { /^from$/i } $msg->header_names;
$from = $msg->header_raw($from);
if ($ENV{LASTMSG_DEBUG}) {
- my $mid = grep { /^message-id$/i } $msg->header_names;
- say STDERR 'Processing ', $msg->header_raw('Message-ID'),
- " from $from" if $ENV{LASTMSG_DEBUG};
+ my ($mid) = grep { /^message-id$/i } $msg->header_names;
+ say STDERR 'Processing ', $msg->header_raw($mid), " from $from";
}
$process_message->($msg, $from);
}
@people = (@people, split /,/, $msg->header_raw($hdr));
}
if ($ENV{LASTMSG_DEBUG}) {
- my $mid = grep { /^message-id$/i } $msg->header_names;
+ my ($mid) = grep { /^message-id$/i } $msg->header_names;
say STDERR 'Processing ', $msg->header_raw($mid),
- ' sent to ', join ',', @people if $ENV{LASTMSG_DEBUG};
+ ' sent to ', join ',', @people;
}
$process_message->($msg, @people);
}
use strict;
use warnings;
-use Test::More tests => 2;
+use Test::More tests => 3;
BEGIN { use_ok('App::Lastmsg') };
{
user1 user1@example.com 1483105440
user3 NOT FOUND
EOF
+
+$ENV{LASTMSG_DEBUG} = 1;
+my $err = '';
+close STDERR;
+open STDERR, '>', \$err or die "$!";
+App::Lastmsg::run;
+
+is $err, <<'EOF', 'debug output is correct';
+Scanning inbox (inbox)
+Processing <mail1@example.com> from User 1 <user1@example.com> (Comment)
+Processing <mail2@example.com> from user1@example.com
+Processing <mail3@example.com> from user2@example.com
+Scanning sent (sent)
+Processing <33r32r32igf432g@localhost.localdomain> sent to Random User <rando@example.com> (Very random), User 2 <user2@example.org>
+EOF