Fixing SMTP sending client
This commit is contained in:
parent
6889d941b8
commit
324c0b1059
2 changed files with 33 additions and 13 deletions
|
@ -18,12 +18,12 @@ use DBI;
|
||||||
use Dotenv;
|
use Dotenv;
|
||||||
use Net::Ping;
|
use Net::Ping;
|
||||||
|
|
||||||
use MIME::Lite;
|
use Email::MIME;
|
||||||
|
use Email::Sender::Simple qw(sendmail);
|
||||||
|
use Email::Sender::Transport::SMTP qw();
|
||||||
|
|
||||||
use LWP::Simple;
|
use LWP::Simple;
|
||||||
use MIME::Base64;
|
|
||||||
use Authen::SASL;
|
|
||||||
use LWP::UserAgent;
|
use LWP::UserAgent;
|
||||||
use IO::Socket::SSL;
|
|
||||||
use LWP::Protocol::https;
|
use LWP::Protocol::https;
|
||||||
|
|
||||||
my $query;
|
my $query;
|
||||||
|
@ -65,6 +65,7 @@ my $smtp_port = $ENV{'SMTP_PORT'};
|
||||||
my $smtp_ssl = $ENV{'SMTP_SSL'};
|
my $smtp_ssl = $ENV{'SMTP_SSL'};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
############################
|
############################
|
||||||
|
|
||||||
######
|
######
|
||||||
|
@ -302,16 +303,35 @@ sub send_notifications {
|
||||||
if ($query->execute()) {
|
if ($query->execute()) {
|
||||||
while ($emails = $query->fetchrow_hashref()) {
|
while ($emails = $query->fetchrow_hashref()) {
|
||||||
|
|
||||||
my $email = new MIME::Lite
|
my $email = Email::MIME->create(
|
||||||
From => 'axel@mabox.eu',
|
header_str => [
|
||||||
To => 'axel@mabox.eu',
|
From => $email_from,
|
||||||
Subject => 'Bla',
|
To => $emails->{'email'},
|
||||||
Type => 'TEXT',
|
Subject => $subject
|
||||||
Data => 'Hello';
|
],
|
||||||
|
parts => [
|
||||||
|
$datas
|
||||||
|
],
|
||||||
|
);
|
||||||
eval {
|
eval {
|
||||||
$email->send('smtp', $smtp_host, Timeout=>5, Auth=>'LOGIN', AuthUser=>$smtp_user, AuthPass=>$smtp_password, Port=>$smtp_port, SSL=>$smtp_ssl, Debug=>0) or output('failed to send notification to ' . $emails->{'email'} . ' (' . $email->error() . ')', 'ERROR');;
|
sendmail(
|
||||||
|
$email,
|
||||||
|
{
|
||||||
|
from => $email_from,
|
||||||
|
transport => Email::Sender::Transport::SMTP->new({
|
||||||
|
host => $smtp_host,
|
||||||
|
port => $smtp_port,
|
||||||
|
sasl_username => $smtp_user,
|
||||||
|
sasl_password => $smtp_password,
|
||||||
|
ssl => $smtp_ssl,
|
||||||
|
timeout => 10
|
||||||
|
})
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
output('Notification email was sent to '.$emails->{'email'}, 'DEBUG');
|
||||||
};
|
};
|
||||||
warn() if $@;
|
warn $@ if $@;
|
||||||
}
|
}
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
<table id="tasks_tbl">
|
<table id="tasks_tbl">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th width="5%"> </th>
|
<th width="5%">Up?</th>
|
||||||
<th width="*">Host</th>
|
<th width="*">Host</th>
|
||||||
<th width="5%">Type</th>
|
<th width="5%">Type</th>
|
||||||
<th width="10%">Parameters</th>
|
<th width="10%">Parameters</th>
|
||||||
|
|
Loading…
Add table
Reference in a new issue