diff --git a/htdocs/admin/mails.php b/htdocs/admin/mails.php
index ef9ac36f3ef..46fea7a992c 100644
--- a/htdocs/admin/mails.php
+++ b/htdocs/admin/mails.php
@@ -32,8 +32,7 @@ $langs->load("mails");
$langs->load("other");
$langs->load("errors");
-if (!$user->admin)
-accessforbidden();
+if (!$user->admin) accessforbidden();
$substitutionarrayfortest=array(
'__LOGIN__' => $user->login,
@@ -44,12 +43,14 @@ $substitutionarrayfortest=array(
);
complete_substitutions_array($substitutionarrayfortest, $langs);
+$action=GETPOST('action');
+
/*
* Actions
*/
-if (isset($_POST["action"]) && $_POST["action"] == 'update' && empty($_POST["cancel"]))
+if ($action == 'update' && empty($_POST["cancel"]))
{
dolibarr_set_const($db, "MAIN_DISABLE_ALL_MAILS", $_POST["MAIN_DISABLE_ALL_MAILS"],'chaine',0,'',$conf->entity);
@@ -159,7 +160,7 @@ if (! empty($_POST['removedfile']) || ! empty($_POST['removedfilehtml']))
/*
* Send mail
*/
-if (($_POST['action'] == 'send' || $_POST['action'] == 'sendhtml')
+if (($action == 'send' || $action == 'sendhtml')
&& ! $_POST['addfile'] && ! $_POST['addfilehtml'] && ! $_POST["removedfile"] && ! $_POST['cancel'])
{
$error=0;
@@ -259,7 +260,7 @@ print_fiche_titre($langs->trans("EMailsSetup"),'','setup');
print $langs->trans("EMailsDesc")."
\n";
print "
\n";
-if ($message) print $message.'
';
+dol_htmloutput_mesg($message);
// List of sending methods
$listofmethods=array();
@@ -268,7 +269,7 @@ $listofmethods['mail']='PHP mail function';
$listofmethods['smtps']='SMTP/SMTPS socket library';
-if (isset($_GET["action"]) && $_GET["action"] == 'edit')
+if ($action == 'edit')
{
$form=new Form($db);
@@ -547,7 +548,7 @@ else
$var=!$var;
if ($conf->global->MAIN_MAIL_SENDMODE == 'smtps')
{
- print '