Skip to content
Snippets Groups Projects
Verified Commit d42b59cc authored by David Beniamine's avatar David Beniamine
Browse files

Utility to test mails

parent fcb2308c
Branches
No related tags found
No related merge requests found
Pipeline #152 failed
#!/usr/bin/perl
# Copyright (C) 2017 Tetras Libre <admin@tetras-libre.fr>
# Author: Beniamine, David <David@Beniamine.net>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
use strict;
use warnings;
use threads ('yield',
'stack_size' => 64*4096,
'exit' => 'threads_only',
'stringify');
use utf8;
use MIME::Lite;
sub do_sendmail($$$);
# Send subject, message by email to root
sub do_sendmail($$$){
my ($subject, $message, $retry) = @_;
utf8::encode($subject);
utf8::encode($message);
my $msg = MIME::Lite->new(
From => 'tetras-back',
To => 'root',
Subject => "[Tetras-back] $subject",
Type => 'multipart/mixed'
);
$msg->attr("content-type.charset" => "UTF-8");
$msg->attach(
Type => 'text/plain; charset=UTF-8',
Data => $message,
);
eval{ $msg->send() };
if($@){
if($retry == 0){
do_sendmail($subject,$message,1);
}
}else{
print("Etat envoyé par courriel");
}
}
do_sendmail("[Tetras-back] Test", "Ceci est un message de test du système de sauvegardes", 0);
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment