summaryrefslogtreecommitdiffstats
path: root/script/imap-notify.pl
blob: f2f7c2c9218d25ba6246bb355e3602e80d357115 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env perl

=head1 DESCRIPTION

Simple notification script using IMAP NOTIFY. Note that it is very simple and
implements a custom IMAP client with very limited features. Mostly a proof of
concept and personal script.

=cut

use v5.24;

use warnings;
use strict;

use App::ImapNotify;
use Function::Parameters;
use MCE::Hobo;
use Log::Any::Adapter ('Stderr', log_level => "warn");

my $config = [
	{
		log_id => "server-speed",
		host => 'mail.server-speed.net',
		port => 993,
		username => 'mail-flo',
		password => trim(`getpw-single msmtp3`),
		mailboxes => [qw(INBOX INBOX.Postmaster INBOX.TISS INBOX.tuwel)],
	},
	#{
		#log_id => "luxx",
		#host => 'mail.nano-srv.net',
		#port => 993,
		#username => 'bluewind@luxx-area.de',
		#password => trim(`getpw-single bluewind\@luxx-area.de`),
		#mailboxes => [qw(INBOX)],
	#},
];

#$IO::Socket::SSL::DEBUG = 4;

my @workers;

for my $single_conf ($config->@*) {
	push @workers, mce_async {
		my $app = App::ImapNotify->new($single_conf);
		$app->loop();
	}
}

map {$_->join()} @workers;

fun trim($string) {
	$string =~ s/^\s+//;
	$string =~ s/\s+$//;
	return $string;
}