diff --git a/src/test-mail b/src/test-mail
deleted file mode 100755
index 1735d4032669e0c0489cdcaca9a770a171e85334..0000000000000000000000000000000000000000
--- a/src/test-mail
+++ /dev/null
@@ -1,57 +0,0 @@
-#!/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("Courriel de test", "Ceci est un message de test du système de sauvegardes", 0);
diff --git a/src/tetras-back b/src/tetras-back
index fd5b011c30aa4938807ad99533f2189007a2a59d..7bb0fef2cdce0accd5473c2cbf4bd6d6ad0c8500 100755
--- a/src/tetras-back
+++ b/src/tetras-back
@@ -137,6 +137,19 @@ sub do_stop($$){
     exit($error);
 }
 
+sub do_tests($){
+    my $test = shift;
+    if($test eq "mail"){
+       do_sendmail("Test", "This is a test message", 0);  
+    }elsif($test eq "end"){
+        end_backup("Test success", 0);
+        end_backup("Test failure", 1);
+    }else{
+        $Logger->alert("Unknown test :'$test'");
+        exit(1);
+    }
+}
+
 # Notify clients of discs modifications
 sub notify(){
     my $json = encode_json($CFG::CFG{DISKS});
@@ -381,6 +394,8 @@ sub start_daemon(){
             notify();
         }elsif ($line =~ /^STOP$/){
             do_stop("Arret demandé par la ligne de commande", 0);
+        }elsif ($line =~ /^TEST (.*)$/){
+            do_tests($1);
         }elsif ($line =~ /^REGISTER (.*)$/){
             $CFG::CFG{CLIENTS}{$1} = time();
             save_config();
@@ -427,6 +442,8 @@ $ap->add_args(
         help=>'Forget the given disc'],
     ['--save', '-s', type=>'Pair', split=>' ', metavar=>'UUID=NAME',
         help=>'Mark disc UUID as known under name'],
+    ['--test', '-t', metavar=>'mail',
+        help=>'Run a test, one of the following : [mail]'],
     ['--plug', '-p', type=>'Scalar', metavar=>"device",
         help=>"Notify $0 that a given device has been pluged, should be called by udev rule"],
     ['--unplug', '-u', type=>'Scalar', metavar=>"device",
@@ -437,6 +454,8 @@ my  $arguments = $ap->parse_args();
 if ($arguments->get_attr('version')){
     print "Tetras-back ".$version."\n";
     exit(0);
+}elsif($arguments->get_attr('test')){
+    send_command("TEST ".$arguments->get_attr('test'));
 }elsif ($arguments->get_attr('start')){
     start_daemon();
 }elsif($arguments->get_attr('stop')){