App-FonBot-Daemon
view release on metacpan or search on metacpan
lib/App/FonBot/Plugin/Email.pm view on Meta::CPAN
$queues{$address}.=$message."\n";
if (defined $queue_alarms{$address}) {
$_[KERNEL]->delay_adjust($queue_alarms{$address}, $email_batch_seconds)
} else {
$queue_alarms{$address}=$_[KERNEL]->delay_set(flush_queue => $email_batch_seconds, $address)
}
}
sub email_flush_queue{
my ($queue) = $_[ARG0];
return unless exists $queues{$queue};
my $email=Email::Simple->create(
header => [
From => $email_from,
To => $queue,
Subject => $email_subject,
],
body => $queues{$queue}
);
delete $queues{$queue};
delete $queue_alarms{$queue};
$log->debug("Sending email to $queue");
eval {
sendmail $email
} or $log->error("Could not send email: " . $@->message);
}
1;
__END__
=encoding utf-8
=head1 NAME
App::FonBot::Plugin::Email - FonBot plugin for receiving commands and sending messages through emails
=head1 SYNOPSIS
use App::FonBot::Plugin::Email;
App::FonBot::Plugin::Email->init;
...
App::FonBot::Plugin::Email->fini;
=head1 DESCRIPTION
This FonBot plugin provides email receiving/sending features to B<fonbotd>. Emails are read from F<Maildir/> and are sent through C<Email::Sender::Simple>.
=head1 CONFIGURATION VARIABLES
These are the L<App::FonBot::Plugin::Config> configuration variables used in this module
=over
=item C<$email_batch_seconds>
When receiving an email send request, C<App::FonBot::Plugin::Email> waits this many seconds for further email send requests to the same email address. The timer is reset for each email send request. When the timer expires, all pending send requests a...
=item C<$email_from>
C<From:> header of all emails sent by this plugin. If not set the email plugin is disabled.
=item C<$email_subject>
C<Subject:> header of all emails sent by this plugin. If not set the email plugin is disabled.
=back
=head1 AUTHOR
Marius Gavrilescu C<< marius@ieval.ro >>
=head1 COPYRIGHT AND LICENSE
Copyright 2013-2015 Marius Gavrilescu
This file is part of fonbotd.
fonbotd is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fonbotd is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with fonbotd. If not, see <http://www.gnu.org/licenses/>
( run in 1.008 second using v1.01-cache-2.11-cpan-39bf76dae61 )