diff --git a/htdocs/admin/mailing.php b/htdocs/admin/mailing.php index 73a0787486b34..84d706f57b4e0 100644 --- a/htdocs/admin/mailing.php +++ b/htdocs/admin/mailing.php @@ -3,6 +3,7 @@ * Copyright (C) 2005-2013 Laurent Destailleur * Copyright (C) 2011-2013 Juanjo Menent * Copyright (C) 2024 Frédéric France + * Copyright (C) 2025 Benjamin Falière * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -26,8 +27,8 @@ // Load Dolibarr environment require '../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/security2.lib.php'; /** * @var Conf $conf @@ -63,11 +64,14 @@ $checkread = GETPOST('value', 'alpha'); $checkread_key = GETPOST('MAILING_EMAIL_UNSUBSCRIBE_KEY', 'alpha'); $contactbulkdefault = GETPOSTINT('MAILING_CONTACT_DEFAULT_BULK_STATUS'); + $batchlimit = GETPOSTINT('MAILING_LIMIT_SENDBYWEB'); + if (GETPOST('MAILING_DELAY', 'alpha') != '') { $mailingdelay = price2num(GETPOST('MAILING_DELAY', 'alpha'), 3); // Not less than 1 millisecond. } else { $mailingdelay = ''; } + // Clean data if ((float) $mailingdelay > 10) { $mailingdelay = 10; @@ -92,6 +96,10 @@ if (!($res > 0)) { $error++; } + $res = dolibarr_set_const($db, "MAILING_LIMIT_SENDBYWEB", $batchlimit, 'chaine', 1, '', 0); + if (!($res > 0)) { + $error++; + } // Create temporary encryption key if needed $res = dolibarr_set_const($db, "MAILING_EMAIL_UNSUBSCRIBE_KEY", $checkread_key, 'chaine', 0, '', $conf->entity); @@ -127,18 +135,18 @@ llxHeader('', $langs->trans("MailingSetup"), '', '', 0, 0, '', '', '', 'mod-admin page-mailing'); -$linkback = ''.$langs->trans("BackToModuleList").''; +$linkback = '' . $langs->trans("BackToModuleList") . ''; print load_fiche_titre($langs->trans("MailingSetup"), $linkback, 'title_setup'); $constname = 'MAILING_EMAIL_UNSUBSCRIBE_KEY'; // Add button to autosuggest a key -include_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; +include_once DOL_DOCUMENT_ROOT . '/core/lib/security2.lib.php'; print dolJSToSetRandomPassword($constname); print '
'; -print '
'; -print ''; +print ''; +print ''; print ''; print ''; @@ -146,32 +154,33 @@ print ''; print ''; print ''; + print "\n"; print ''; -print ''; +print ''; print ''; print ''; -print ''; +print ''; print ''; print ''; print ''; print ''; @@ -181,10 +190,10 @@ // It is also used as a security key parameter. print ''; print ''; @@ -194,16 +203,27 @@ print ''; print ''; print ''; print ''; print ''; +// Limit number for each mailing batch, displayed only if this value is not defined in the conf.php file +if (empty($conf->file->mailing_limit_sendbyweb)) { + print ''; + $help = img_help(1, $langs->trans("MailingNumberOfEmailsPerBatchHelp")); + print ''; + print ''; + print ''; + print ''; +} if (!empty($conf->use_javascript_ajax) && getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 1) { print ''; print ''; diff --git a/htdocs/install/mysql/data/llx_const.sql b/htdocs/install/mysql/data/llx_const.sql index 9b698b6ebee65..0b56ef34d24ba 100644 --- a/htdocs/install/mysql/data/llx_const.sql +++ b/htdocs/install/mysql/data/llx_const.sql @@ -33,8 +33,7 @@ -- Visible in misc page and common to all entities insert into llx_const (name, value, type, note, visible, entity) values ('MAIN_NOT_INSTALLED','1','chaine','Setup is running',1,0); -insert into llx_const (name, value, type, note, visible, entity) values ('MAILING_LIMIT_SENDBYWEB','25','chaine','Number of targets to defined packet size when sending mass email',1,0); ---insert into llx_const (name, value, type, note, visible, entity) values ('MAIN_ENABLE_LOG_TO_HTML','0','chaine','If this option is set to 1, it is possible to see log output at end of HTML sources by adding parameter logtohtml=1 on URL. Module log must also be enabled.',1,0); +--insert into llx_const (name, value, type, note, visible, entity) values ('MAIN_ENABLE_LOG_TO_HTML','0','chaine','If this option is set to 1, it is possible to see log output at end of HTML sources by adding paramater logtohtml=1 on URL. Module log must also be enabled.',1,0); -- Visible in misc page but specific to one entity insert into llx_const (name, value, type, note, visible, entity) values ('MAIN_FEATURES_LEVEL','0','chaine','Level of features to show: -1=stable+deprecated, 0=stable only (default), 1=stable+experimental, 2=stable+experimental+development',1,__ENTITY__); @@ -43,6 +42,8 @@ insert into llx_const (name, value, type, note, visible, entity) values ('MAIN_F insert into llx_const (name, value, type, note, visible, entity) values ('SYSLOG_HANDLERS','["mod_syslog_file"]','chaine','Which logger to use',0,0); insert into llx_const (name, value, type, note, visible, entity) values ('SYSLOG_FILE','DOL_DATA_ROOT/dolibarr.log','chaine','Directory where to write log file',0,0); insert into llx_const (name, value, type, note, visible, entity) values ('SYSLOG_LEVEL','7','chaine','Level of debug info to show',0,0); +insert into llx_const (name, value, type, note, visible, entity) values ('MAILING_LIMIT_SENDBYWEB','25','chaine','Number of targets to defined packet size when sending mass email',0,0); + -- Hidden but specific to one entity insert into llx_const (name, value, type, note, visible, entity) values ('MAIN_UPLOAD_DOC','2048','chaine','Max size for file upload (0 means no upload allowed)',0,__ENTITY__); diff --git a/htdocs/install/mysql/migration/21.0.0-22.0.0.sql b/htdocs/install/mysql/migration/21.0.0-22.0.0.sql index 16d65d4d54f70..e37a288296cea 100644 --- a/htdocs/install/mysql/migration/21.0.0-22.0.0.sql +++ b/htdocs/install/mysql/migration/21.0.0-22.0.0.sql @@ -63,6 +63,8 @@ ALTER TABLE llx_societe_account ADD COLUMN ip varchar(250); ALTER TABLE llx_product ADD COLUMN packaging float(24,8) DEFAULT NULL; +-- mailing +UPDATE llx_const SET visible = 0 WHERE name='MAILING_LIMIT_SENDBYWEB'; ALTER TABLE llx_categorie_member ADD COLUMN import_key varchar(14); ALTER TABLE llx_category_bankline ADD COLUMN import_key varchar(14); diff --git a/htdocs/langs/en_US/mails.lang b/htdocs/langs/en_US/mails.lang index b7ca6c62f19ee..ca93658f31902 100644 --- a/htdocs/langs/en_US/mails.lang +++ b/htdocs/langs/en_US/mails.lang @@ -204,3 +204,5 @@ ContentOfMailHolder=Content of email goes here... LastNews=Latest News ListProducts= List of products PasswordReset=Password reset +MailingNumberOfEmailsPerBatch=Number of emails per batch +MailingNumberOfEmailsPerBatchHelp=Define the number of emails you want to send for each manual sending action. Warning: An important number of emails can lead to your server being blacklisted.
'.$langs->trans("Parameter").''.$langs->trans("Example").'
'; $help = img_help(1, $langs->trans("EMailHelpMsgSPFDKIM")); -print $langs->trans("MailingEMailFrom").' '.$help.''; -print ''; +print $langs->trans("MailingEMailFrom") . ' ' . $help . ''; +print ''; if (getDolGlobalString('MAILING_EMAIL_FROM') && !isValidEmail($conf->global->MAILING_EMAIL_FROM)) { - print ' '.img_warning($langs->trans("BadEMail")); + print ' ' . img_warning($langs->trans("BadEMail")); } print ''.dol_escape_htmltag(($mysoc->name ? $mysoc->name : 'MyName').' ').'' . dol_escape_htmltag(($mysoc->name ? $mysoc->name : 'MyName') . ' ') . '
'; -print $langs->trans("MailingEMailError").''; -print ''; +print $langs->trans("MailingEMailError") . ''; +print ''; if (getDolGlobalString('MAILING_EMAIL_ERRORSTO') && !isValidEmail(getDolGlobalString('MAILING_EMAIL_ERRORSTO'))) { - print ' '.img_warning($langs->trans("BadEMail")); + print ' ' . img_warning($langs->trans("BadEMail")); } print ''.dol_escape_htmltag('').'' . dol_escape_htmltag('') . '
'; -print $form->textwithpicto($langs->trans("MailingDelay"), $langs->trans("IfDefinedUseAValueBeetween", '0.001', '10')).''; -print ''; +print $form->textwithpicto($langs->trans("MailingDelay"), $langs->trans("IfDefinedUseAValueBeetween", '0.001', '10')) . ''; +print ''; print '
'; -print $langs->trans("ActivateCheckReadKey").''; -print ''; +print $langs->trans("ActivateCheckReadKey") . ''; +print ''; if (!empty($conf->use_javascript_ajax)) { - print ' '.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token" class="linkobject"'); + print ' ' . img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token" class="linkobject"'); } print '
' . $langs->trans("DefaultBlacklistMailingStatus", $langs->transnoentitiesnoconv("No_Email")) . ''; -$blacklist_setting=array(0=>$langs->trans('No'), 1=>$langs->trans('Yes'), 2=>$langs->trans('DefaultStatusEmptyMandatory')); +$blacklist_setting = array(0 => $langs->trans('No'), 1 => $langs->trans('Yes'), 2 => $langs->trans('DefaultStatusEmptyMandatory')); print $form->selectarray("MAILING_CONTACT_DEFAULT_BULK_STATUS", $blacklist_setting, getDolGlobalString('MAILING_CONTACT_DEFAULT_BULK_STATUS')); print '
' . $langs->trans("MailingNumberOfEmailsPerBatch") . ' ' . $help . ''; + print ''; + print '
'; - print $langs->trans("MailAdvTargetRecipients").''; + print $langs->trans("MailAdvTargetRecipients") . ''; print ajax_constantonoff('EMAILING_USE_ADVANCED_SELECTOR'); print '