diff options
author | Florian Pritz <bluewind@xinu.at> | 2018-07-17 15:26:40 +0200 |
---|---|---|
committer | Florian Pritz <bluewind@xinu.at> | 2018-07-17 15:26:40 +0200 |
commit | 50a37d8812c95c60203b0102db91f0c080d4d93b (patch) | |
tree | 86d1c9b2e5461e872fdfbcb207a4e07a9f37283e /script | |
parent | 6e43e5e33b7d4fceaadb42e8264a7319002848cb (diff) | |
download | App-ImapNotify-50a37d8812c95c60203b0102db91f0c080d4d93b.tar.gz App-ImapNotify-50a37d8812c95c60203b0102db91f0c080d4d93b.tar.xz |
Initial port of single file script
Signed-off-by: Florian Pritz <bluewind@xinu.at>
Diffstat (limited to 'script')
-rwxr-xr-x | script/imap-notify.pl | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/script/imap-notify.pl b/script/imap-notify.pl new file mode 100755 index 0000000..f2f7c2c --- /dev/null +++ b/script/imap-notify.pl @@ -0,0 +1,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; +} + |