From 8c65c47b1f9185342406c10d88310cdddb9e0b76 Mon Sep 17 00:00:00 2001 From: De Coninck Laurent Date: Fri, 17 Mar 2017 17:55:25 +0100 Subject: [PATCH] fix the from e-mail on mass action In mass action e-mail (like on facture), the from e-mail was not taken into account. --- htdocs/core/actions_massactions.inc.php | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 3acb974deae..95c0c59a9cd 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -209,7 +209,26 @@ if (! $error && $massaction == 'confirm_presend') if (count($listofqualifiedinvoice) > 0) { $langs->load("commercial"); - $from = $user->getFullName($langs) . ' <' . $user->email .'>'; + + $fromtype = GETPOST('fromtype'); + if ($fromtype === 'user') { + $from = $user->getFullName($langs) .' <'.$user->email.'>'; + } + elseif ($fromtype === 'company') { + $from = $conf->global->MAIN_INFO_SOCIETE_NOM .' <'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'>'; + } + elseif (preg_match('/user_aliases_(\d+)/', $fromtype, $reg)) { + $tmp=explode(',', $user->email_aliases); + $from = trim($tmp[($reg[1] - 1)]); + } + elseif (preg_match('/global_aliases_(\d+)/', $fromtype, $reg)) { + $tmp=explode(',', $conf->global->MAIN_INFO_SOCIETE_MAIL_ALIASES); + $from = trim($tmp[($reg[1] - 1)]); + } + else { + $from = $_POST['fromname'] . ' <' . $_POST['frommail'] .'>'; + } + $replyto = $from; $subject = GETPOST('subject'); $message = GETPOST('message');