From 50a37d8812c95c60203b0102db91f0c080d4d93b Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Tue, 17 Jul 2018 15:26:40 +0200 Subject: Initial port of single file script Signed-off-by: Florian Pritz --- script/imap-notify.pl | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100755 script/imap-notify.pl (limited to 'script') 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; +} + -- cgit v1.2.3-24-g4f1b