Fix limit to send emails
This commit is contained in:
parent
131c4f8ca8
commit
f29ed4b045
@ -39,14 +39,20 @@ if (substr($sapi_type, 0, 3) == 'cgi') {
|
||||
}
|
||||
|
||||
if (!isset($argv[1]) || !$argv[1]) {
|
||||
print "Usage: ".$script_file." (ID_MAILING|all)\n";
|
||||
print "Usage: ".$script_file." (ID_MAILING|all) [userloginforsignature] [maxnbofemails]\n";
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
$id = $argv[1];
|
||||
if (isset($argv[2]) || !empty($argv[2]))
|
||||
$login = $argv[2];
|
||||
|
||||
if (isset($argv[2]) || !empty($argv[2])) $login = $argv[2];
|
||||
else $login = '';
|
||||
|
||||
$max = 0;
|
||||
|
||||
if (isset($argv[3]) || !empty($argv[3])) $max = $argv[3];
|
||||
|
||||
|
||||
require_once $path."../../htdocs/master.inc.php";
|
||||
require_once DOL_DOCUMENT_ROOT."/core/class/CMailFile.class.php";
|
||||
require_once DOL_DOCUMENT_ROOT."/comm/mailing/class/mailing.class.php";
|
||||
@ -113,9 +119,13 @@ if ($resql) {
|
||||
// ou envoyes en erreur (statut=-1)
|
||||
$sql2 = "SELECT mc.rowid, mc.fk_mailing, mc.lastname, mc.firstname, mc.email, mc.other, mc.source_url, mc.source_id, mc.source_type, mc.tag";
|
||||
$sql2 .= " FROM ".MAIN_DB_PREFIX."mailing_cibles as mc";
|
||||
$sql2 .= " WHERE mc.statut < 1 AND mc.fk_mailing = ".$id;
|
||||
if ($conf->global->MAILING_LIMIT_SENDBYCLI > 0) {
|
||||
$sql2 .= " WHERE mc.statut < 1 AND mc.fk_mailing = ".((int) $id);
|
||||
if ($conf->global->MAILING_LIMIT_SENDBYCLI > 0 && empty($max)) {
|
||||
$sql2 .= " LIMIT ".$conf->global->MAILING_LIMIT_SENDBYCLI;
|
||||
} elseif ($conf->global->MAILING_LIMIT_SENDBYCLI > 0 && $max > 0) {
|
||||
$sql2 .= " LIMIT ".min($conf->global->MAILING_LIMIT_SENDBYCLI, $max);
|
||||
} elseif ($max > 0) {
|
||||
$sql2 .= " LIMIT ".$max;
|
||||
}
|
||||
|
||||
$resql2 = $db->query($sql2);
|
||||
@ -128,7 +138,7 @@ if ($resql) {
|
||||
$now = dol_now();
|
||||
|
||||
// Positionne date debut envoi
|
||||
$sqlstartdate = "UPDATE ".MAIN_DB_PREFIX."mailing SET date_envoi='".$db->idate($now)."' WHERE rowid=".$id;
|
||||
$sqlstartdate = "UPDATE ".MAIN_DB_PREFIX."mailing SET date_envoi='".$db->idate($now)."' WHERE rowid=".((int) $id);
|
||||
$resqlstartdate = $db->query($sqlstartdate);
|
||||
if (!$resqlstartdate) {
|
||||
dol_print_error($db);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user