diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php index c3ef480d2ae..a520a44e467 100644 --- a/htdocs/comm/mailing/card.php +++ b/htdocs/comm/mailing/card.php @@ -265,9 +265,10 @@ if (empty($reshook)) { } //$substitutionisok=true; + $moreinheader = ''; complete_substitutions_array($substitutionarray, $langs); $newsubject = make_substitutions($subject, $substitutionarray); - $newmessage = make_substitutions($message, $substitutionarray); + $newmessage = make_substitutions($message, $substitutionarray, null, 0, $moreinheader); $arr_file = array(); $arr_mime = array(); @@ -285,7 +286,7 @@ if (empty($reshook)) { // Mail making $trackid = 'emailing-'.$obj->fk_mailing.'-'.$obj->rowid; - $mail = new CMailFile($newsubject, $sendto, $from, $newmessage, $arr_file, $arr_mime, $arr_name, '', '', 0, $msgishtml, $errorsto, $arr_css, $trackid, '', 'emailing'); + $mail = new CMailFile($newsubject, $sendto, $from, $newmessage, $arr_file, $arr_mime, $arr_name, '', '', 0, $msgishtml, $errorsto, $arr_css, $trackid, $moreinheader, 'emailing'); if ($mail->error) { $res = 0; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 5eda236d6f0..b017f9c037b 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -7206,10 +7206,11 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, * @param Translate $outputlangs Output language * @param int $converttextinhtmlifnecessary 0=Convert only value into HTML if text is already in HTML * 1=Will also convert initial $text into HTML if we try to insert one value that is HTML + * @param string $moreinheader Header for CMailer module * @return string Output string after substitutions * @see complete_substitutions_array(), getCommonSubstitutionArray() */ -function make_substitutions($text, $substitutionarray, $outputlangs = null, $converttextinhtmlifnecessary = 0) +function make_substitutions($text, $substitutionarray, $outputlangs = null, $converttextinhtmlifnecessary = 0, &$moreinheader = null) { global $conf, $langs; @@ -7312,9 +7313,12 @@ function make_substitutions($text, $substitutionarray, $outputlangs = null, $con } else { $value = dol_nl2br("$value"); } - $text = str_replace("$key", "$value", $text); // We must keep the " to work when value is 123.5 for example } + if ($key == '__UNSUBSCRIBE__' && (isset($moreinheader))) { + $tmptext = explode('"', $text); + $moreinheader = "List-Unsubscribe: <".$tmptext[1].">\n"; + } } return $text;