Merge branch '17.0' of git@github.com:Dolibarr/dolibarr.git into develop
This commit is contained in:
commit
1c9884e604
@ -203,9 +203,9 @@ if (empty($reshook)) {
|
|||||||
|
|
||||||
$thirdpartystatic = new Societe($db);
|
$thirdpartystatic = new Societe($db);
|
||||||
// Loop on each email and send it
|
// 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
|
// Here code is common with same loop ino mailing-send.php
|
||||||
$res = 1;
|
$res = 1;
|
||||||
$now = dol_now();
|
$now = dol_now();
|
||||||
@ -367,7 +367,7 @@ if (empty($reshook)) {
|
|||||||
// Mail successful
|
// Mail successful
|
||||||
$nbok++;
|
$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 = "UPDATE ".MAIN_DB_PREFIX."mailing_cibles";
|
||||||
$sql .= " SET statut=1, date_envoi = '".$db->idate($now)."' WHERE rowid=".((int) $obj->rowid);
|
$sql .= " SET statut=1, date_envoi = '".$db->idate($now)."' WHERE rowid=".((int) $obj->rowid);
|
||||||
@ -406,7 +406,7 @@ if (empty($reshook)) {
|
|||||||
// Mail failed
|
// Mail failed
|
||||||
$nbko++;
|
$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 = "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);
|
$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 {
|
} else {
|
||||||
setEventMessages($langs->transnoentitiesnoconv("NoMoreRecipientToSendTo"), null, 'mesgs');
|
setEventMessages($langs->transnoentitiesnoconv("NoMoreRecipientToSendTo"), null, 'mesgs');
|
||||||
|
|||||||
@ -256,12 +256,14 @@ class CMailFile
|
|||||||
$this->html = $msg;
|
$this->html = $msg;
|
||||||
|
|
||||||
$findimg = 0;
|
$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
|
// 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.
|
// 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
|
// 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');
|
$findimg = $this->findHtmlImages($dolibarr_main_data_root.'/medias');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($conf->global->MAIN_MAIL_ADD_INLINE_IMAGES_IF_DATA)) {
|
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
|
// 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
|
// 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];
|
$this->html_images[$i]["content_type"] = $this->image_types[$ext];
|
||||||
}
|
}
|
||||||
// cid
|
// 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
|
// type
|
||||||
$this->html_images[$i]["type"] = 'cidfromurl';
|
$this->html_images[$i]["type"] = 'cidfromurl';
|
||||||
|
|
||||||
@ -1805,17 +1807,22 @@ class CMailFile
|
|||||||
foreach ($matches[1] as $key => $ext) {
|
foreach ($matches[1] as $key => $ext) {
|
||||||
// We save the image to send in disk
|
// We save the image to send in disk
|
||||||
$filecontent = $matches[2][$key];
|
$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;
|
$destfiletmp = $images_dir.'/'.$cid.'.'.$ext;
|
||||||
|
|
||||||
$fhandle = @fopen($destfiletmp, 'w');
|
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)
|
||||||
if ($fhandle) {
|
dol_syslog("write the cid file ".$destfiletmp);
|
||||||
$nbofbyteswrote = fwrite($fhandle, base64_decode($filecontent));
|
$fhandle = @fopen($destfiletmp, 'w');
|
||||||
fclose($fhandle);
|
if ($fhandle) {
|
||||||
dolChmod($destfiletmp);
|
$nbofbyteswrote = fwrite($fhandle, base64_decode($filecontent));
|
||||||
} else {
|
fclose($fhandle);
|
||||||
$this->errors[] = "Failed to open file '".$destfiletmp."' for write";
|
dolChmod($destfiletmp);
|
||||||
return -1;
|
} else {
|
||||||
|
$this->errors[] = "Failed to open file '".$destfiletmp."' for write";
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (file_exists($destfiletmp)) {
|
if (file_exists($destfiletmp)) {
|
||||||
|
|||||||
@ -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
|
DefaultBlacklistMailingStatus=Default value for field '%s' when creating a new contact
|
||||||
DefaultStatusEmptyMandatory=Empty but mandatory
|
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.
|
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
|
||||||
Loading…
Reference in New Issue
Block a user