Merge branch '17.0' of git@github.com:Dolibarr/dolibarr.git into develop

This commit is contained in:
Laurent Destailleur 2023-02-25 04:10:25 +01:00
commit 1c9884e604
3 changed files with 24 additions and 16 deletions

View File

@ -203,9 +203,9 @@ if (empty($reshook)) {
$thirdpartystatic = new Societe($db);
// Loop on each email and send it
$i = 0;
$iforemailloop = 0;
while ($i < $num && $i < $conf->global->MAILING_LIMIT_SENDBYWEB) {
while ($iforemailloop < $num && $iforemailloop < $conf->global->MAILING_LIMIT_SENDBYWEB) {
// Here code is common with same loop ino mailing-send.php
$res = 1;
$now = dol_now();
@ -367,7 +367,7 @@ if (empty($reshook)) {
// Mail successful
$nbok++;
dol_syslog("comm/mailing/card.php: ok for #".$i.($mail->error ? ' - '.$mail->error : ''), LOG_DEBUG);
dol_syslog("comm/mailing/card.php: ok for #".$iforemailloop.($mail->error ? ' - '.$mail->error : ''), LOG_DEBUG);
$sql = "UPDATE ".MAIN_DB_PREFIX."mailing_cibles";
$sql .= " SET statut=1, date_envoi = '".$db->idate($now)."' WHERE rowid=".((int) $obj->rowid);
@ -406,7 +406,7 @@ if (empty($reshook)) {
// Mail failed
$nbko++;
dol_syslog("comm/mailing/card.php: error for #".$i.($mail->error ? ' - '.$mail->error : ''), LOG_WARNING);
dol_syslog("comm/mailing/card.php: error for #".$iforemailloop.($mail->error ? ' - '.$mail->error : ''), LOG_WARNING);
$sql = "UPDATE ".MAIN_DB_PREFIX."mailing_cibles";
$sql .= " SET statut=-1, error_text='".$db->escape($mail->error)."', date_envoi='".$db->idate($now)."' WHERE rowid=".((int) $obj->rowid);
@ -416,7 +416,7 @@ if (empty($reshook)) {
}
}
$i++;
$iforemailloop++;
}
} else {
setEventMessages($langs->transnoentitiesnoconv("NoMoreRecipientToSendTo"), null, 'mesgs');

View File

@ -256,12 +256,14 @@ class CMailFile
$this->html = $msg;
$findimg = 0;
if (!empty($conf->global->MAIN_MAIL_ADD_INLINE_IMAGES_IF_IN_MEDIAS)) {
if (!empty($conf->global->MAIN_MAIL_ADD_INLINE_IMAGES_IF_IN_MEDIAS)) { // Off by default
// Search into the body for <img tags of links in medias files to replace them with an embedded file
// Note because media links are public, this should be useless, except avoid blocking images with email browser.
// This convert an embedd file with src="/viewimage.php?modulepart... into a cid link
// TODO Exclude viewimage used for the read tracker ?
$findimg = $this->findHtmlImages($dolibarr_main_data_root.'/medias');
}
if (!empty($conf->global->MAIN_MAIL_ADD_INLINE_IMAGES_IF_DATA)) {
// Search into the body for <img src="data:image/ext;base64,..." to replace them with an embedded file
// This convert an embedded file with src="data:image... into a cid link + attached file
@ -1713,7 +1715,7 @@ class CMailFile
$this->html_images[$i]["content_type"] = $this->image_types[$ext];
}
// cid
$this->html_images[$i]["cid"] = dol_hash(uniqid(time()), 3); // Force md5 hash (does not contains special chars)
$this->html_images[$i]["cid"] = dol_hash($this->html_images[$i]["fullpath"], 'md5'); // Force md5 hash (does not contains special chars)
// type
$this->html_images[$i]["type"] = 'cidfromurl';
@ -1805,17 +1807,22 @@ class CMailFile
foreach ($matches[1] as $key => $ext) {
// We save the image to send in disk
$filecontent = $matches[2][$key];
$cid = 'cid000'.dol_hash($this->html, 'md5'); // The id must not change if image is same
$cid = 'cid000'.dol_hash($filecontent, 'md5'); // The id must not change if image is same
$destfiletmp = $images_dir.'/'.$cid.'.'.$ext;
$fhandle = @fopen($destfiletmp, 'w');
if ($fhandle) {
$nbofbyteswrote = fwrite($fhandle, base64_decode($filecontent));
fclose($fhandle);
dolChmod($destfiletmp);
} else {
$this->errors[] = "Failed to open file '".$destfiletmp."' for write";
return -1;
if (!dol_is_file($destfiletmp)) { // If file does not exist yet (this is the case for the first email sent with a data:image inside)
dol_syslog("write the cid file ".$destfiletmp);
$fhandle = @fopen($destfiletmp, 'w');
if ($fhandle) {
$nbofbyteswrote = fwrite($fhandle, base64_decode($filecontent));
fclose($fhandle);
dolChmod($destfiletmp);
} else {
$this->errors[] = "Failed to open file '".$destfiletmp."' for write";
return -1;
}
}
if (file_exists($destfiletmp)) {

View File

@ -179,3 +179,4 @@ RecordCreatedByEmailCollector=Record created by the Email Collector %s from emai
DefaultBlacklistMailingStatus=Default value for field '%s' when creating a new contact
DefaultStatusEmptyMandatory=Empty but mandatory
WarningLimitSendByDay=WARNING: The setup or contract of your instance limits your number of emails per day to <b>%s</b>. Trying to send more may result in having your instance slow down or suspended. Please contact your support if you need a higher quota.
NoMoreRecipientToSendTo=No more recipient to send the email to