Merge pull request #17489 from Hystepik/develop#1

Fix  #17475 : Add of List-Unsubscribe in mass emailing
This commit is contained in:
Laurent Destailleur 2021-05-17 10:23:21 +02:00 committed by GitHub
commit d0c634a99c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 4 deletions

View File

@ -281,7 +281,13 @@ if (empty($reshook)) {
complete_substitutions_array($substitutionarray, $langs);
$newsubject = make_substitutions($subject, $substitutionarray);
$newmessage = make_substitutions($message, $substitutionarray);
$newmessage = make_substitutions($message, $substitutionarray, null, 0);
$moreinheader = '';
if (preg_match('/__UNSUBSCRIBE__/', $message)) {
$moreinheader = "List-Unsubscribe: <__UNSUBSCRIBE_URL__>\n";
$moreinheader = make_substitutions($moreinheader, $substitutionarray);
}
$arr_file = array();
$arr_mime = array();
@ -299,7 +305,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;

View File

@ -7317,7 +7317,6 @@ 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
}
}

View File

@ -269,6 +269,12 @@ if ($resql) {
$substitutionisok = true;
$moreinheader = '';
if (preg_match('/__UNSUBSCRIBE__/', $message)) {
$moreinheader = "List-Unsubscribe: <__UNSUBSCRIBE_URL__>\n";
$moreinheader = make_substitutions($moreinheader, $substitutionarray);
}
$arr_file = array();
$arr_mime = array();
$arr_name = array();
@ -285,7 +291,7 @@ if ($resql) {
}
// Fabrication du mail
$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;