diff --git a/ChangeLog b/ChangeLog index 66e74ed8675fdc6ebaf5c3981dee14a4d9dabc36..9524185818f180eaee71be88fa1a5e873e46403f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -18,6 +18,7 @@ For users: - New: Add more volume units (ounce, gallon, inch, feet, ...) - New: Delivery date accepts hours and minutes. - New: Can add a comment on stock dispatching to be save into stock movements. +- New: Add option to send all emails sent to a bulk carbon copy. - Perf: Avoid reading database to determine country code after each page call. - Fix: Better Postgresql compatibility. diff --git a/htdocs/admin/mails.php b/htdocs/admin/mails.php index cd477be5995da198fc5fb6d49e6c76789c4a4472..10a84f73c08acac51183887ef85b3e1df716586c 100644 --- a/htdocs/admin/mails.php +++ b/htdocs/admin/mails.php @@ -19,7 +19,7 @@ /** * \file htdocs/admin/mails.php - * \brief Page de configuration des emails + * \brief Page to setup emails sending * \version $Id$ */ @@ -31,6 +31,7 @@ $langs->load("products"); $langs->load("admin"); $langs->load("mails"); $langs->load("other"); +$langs->load("errors"); if (!$user->admin) accessforbidden(); @@ -57,6 +58,7 @@ if (isset($_POST["action"]) && $_POST["action"] == 'update') if (isset($_POST["MAIN_MAIL_SMTPS_PW"])) dolibarr_set_const($db, "MAIN_MAIL_SMTPS_PW", $_POST["MAIN_MAIL_SMTPS_PW"],'chaine',0,'',0); if (isset($_POST["MAIN_MAIL_EMAIL_TLS"])) dolibarr_set_const($db, "MAIN_MAIL_EMAIL_TLS", $_POST["MAIN_MAIL_EMAIL_TLS"],'chaine',0,'',0); dolibarr_set_const($db, "MAIN_MAIL_EMAIL_FROM", $_POST["MAIN_MAIL_EMAIL_FROM"],'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "MAIN_MAIL_AUTOCOPY_TO", $_POST["MAIN_MAIL_AUTOCOPY_TO"],'chaine',0,'',$conf->entity); Header("Location: ".$_SERVER["PHP_SELF"]."?mainmenu=home&leftmenu=setup"); exit; @@ -280,6 +282,10 @@ if (isset($_GET["action"]) && $_GET["action"] == 'edit') print $html->selectyesno('MAIN_DISABLE_ALL_MAILS',$conf->global->MAIN_DISABLE_ALL_MAILS,1); print '</td></tr>'; + // Separator + $var=!$var; + print '<tr '.$bc[$var].'><td colspan="2"> </td></tr>'; + // Method $var=!$var; print '<tr '.$bc[$var].'><td>'.$langs->trans("MAIN_MAIL_SENDMODE").'</td><td>'; @@ -409,10 +415,21 @@ if (isset($_GET["action"]) && $_GET["action"] == 'edit') else print yn(0).' ('.$langs->trans("NotSupported").')'; print '</td></tr>'; + // Separator + $var=!$var; + print '<tr '.$bc[$var].'><td colspan="2"> </td></tr>'; + // From $var=!$var; - print '<tr '.$bc[$var].'><td>'.$langs->trans("MAIN_MAIL_EMAIL_FROM",ini_get('sendmail_from')?ini_get('sendmail_from'):$langs->transnoentities("Undefined")).'</td><td><input class="flat" name="MAIN_MAIL_EMAIL_FROM" size="32" value="' . $conf->global->MAIN_MAIL_EMAIL_FROM . '"></td></tr>'; + print '<tr '.$bc[$var].'><td>'.$langs->trans("MAIN_MAIL_EMAIL_FROM",ini_get('sendmail_from')?ini_get('sendmail_from'):$langs->transnoentities("Undefined")).'</td>'; + print '<td><input class="flat" name="MAIN_MAIL_EMAIL_FROM" size="32" value="' . $conf->global->MAIN_MAIL_EMAIL_FROM; + print '"></td></tr>'; + // Autocopy to + $var=!$var; + print '<tr '.$bc[$var].'><td>'.$langs->trans("MAIN_MAIL_AUTOCOPY_TO").'</td>'; + print '<td><input class="flat" name="MAIN_MAIL_AUTOCOPY_TO" size="32" value="' . $conf->global->MAIN_MAIL_AUTOCOPY_TO; + print '"></td></tr>'; print '</table>'; print '<br><center>'; @@ -433,6 +450,10 @@ else $var=!$var; print '<tr '.$bc[$var].'><td>'.$langs->trans("MAIN_DISABLE_ALL_MAILS").'</td><td>'.yn($conf->global->MAIN_DISABLE_ALL_MAILS).'</td></tr>'; + // Separator + $var=!$var; + print '<tr '.$bc[$var].'><td colspan="2"> </td></tr>'; + // Method $var=!$var; print '<tr '.$bc[$var].'><td>'.$langs->trans("MAIN_MAIL_SENDMODE").'</td><td>'; @@ -491,9 +512,23 @@ else else print yn(0).' ('.$langs->trans("NotSupported").')'; print '</td></tr>'; + // Separator + $var=!$var; + print '<tr '.$bc[$var].'><td colspan="2"> </td></tr>'; + // From $var=!$var; - print '<tr '.$bc[$var].'><td>'.$langs->trans("MAIN_MAIL_EMAIL_FROM",ini_get('sendmail_from')?ini_get('sendmail_from'):$langs->transnoentities("Undefined")).'</td><td>'.$conf->global->MAIN_MAIL_EMAIL_FROM.'</td></tr>'; + print '<tr '.$bc[$var].'><td>'.$langs->trans("MAIN_MAIL_EMAIL_FROM",ini_get('sendmail_from')?ini_get('sendmail_from'):$langs->transnoentities("Undefined")).'</td>'; + print '<td>'.$conf->global->MAIN_MAIL_EMAIL_FROM; + if (!empty($conf->global->MAIN_MAIL_EMAIL_FROM) && ! isValidEmail($conf->global->MAIN_MAIL_EMAIL_FROM)) print img_warning($langs->trans("ErrorBadEMail")); + print '</td></tr>'; + + // Autocopy to + $var=!$var; + print '<tr '.$bc[$var].'><td>'.$langs->trans("MAIN_MAIL_AUTOCOPY_TO").'</td>'; + print '<td>'.$conf->global->MAIN_MAIL_AUTOCOPY_TO; + if (!empty($conf->global->MAIN_MAIL_AUTOCOPY_TO) && ! isValidEmail($conf->global->MAIN_MAIL_AUTOCOPY_TO)) print img_warning($langs->trans("ErrorBadEMail")); + print '</td></tr>'; print '</table>'; diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index be6b713f94926b139b6932efb8e653477f90fea5..c8e68ed4dc2fba2e7b57cd25db7387d11d4894cb 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -387,6 +387,7 @@ class FormMail print $form->selectarray("receiverccc", $liste, isset($_REQUEST["receiverccc"])?$_REQUEST["receiverccc"]:0); } } + //if (! empty($conf->global->MAIN_MAIL_AUTOCOPY_TO)) print ' '.info_admin("+ ".$conf->global->MAIN_MAIL_AUTOCOPY_TO,1); print "</td></tr>\n"; } diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 6cf75efbd30109fff13b47e356e3432ec95bc964..e81805c2edc712b5c33cf0474c17c83339fa4697 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -213,6 +213,7 @@ MAIN_MAIL_SMTP_SERVER=SMTP/SMTPS Host (By default in php.ini: <b>%s</b>) MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike=SMTP/SMTPS Port (Not defined into PHP on Unix like systems) MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike=SMTP/SMTPS Host (Not defined into PHP on Unix like systems) MAIN_MAIL_EMAIL_FROM=Sender e-mail for automatic emails (By default in php.ini: <b>%s</b>) +MAIN_MAIL_AUTOCOPY_TO= Send systematically a hidden carbon-copy of all sent emails to MAIN_DISABLE_ALL_MAILS=Disable all e-mails sendings (for test purposes or demos) MAIN_MAIL_SENDMODE=Method to use to send EMails MAIN_MAIL_SMTPS_ID=SMTP ID if authentication required diff --git a/htdocs/langs/fr_FR/admin.lang b/htdocs/langs/fr_FR/admin.lang index bd6d8b117b0181bd87f1db0e01866afed44e4ba0..8b209aea829a3edc4374df53907ab554b6eda8ce 100644 --- a/htdocs/langs/fr_FR/admin.lang +++ b/htdocs/langs/fr_FR/admin.lang @@ -213,6 +213,7 @@ MAIN_MAIL_SMTP_SERVER= Nom host ou ip du serveur SMTP/SMTPS (Par défaut dans ph MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike= Port du serveur SMTP/SMTPS (Non défini dans le PHP sur les systèmes de type Unix) MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike= Nom host ou ip du serveur SMTP/SMTPS (Non défini dans le PHP sur les systèmes de type Unix) MAIN_MAIL_EMAIL_FROM= EMail émetteur pour envoi emails automatiques (Par défaut dans php.ini: <b>%s</b>) +MAIN_MAIL_AUTOCOPY_TO= Envoyer systématiquement une copie cachée des mails envoyés à MAIN_DISABLE_ALL_MAILS= Désactiver globalement tout envoi de mails (pour mode test ou démos) MAIN_MAIL_SENDMODE= Méthode d'envoi des mails MAIN_MAIL_SMTPS_ID= SMTP Authentification ID si authentification SMTP requise diff --git a/htdocs/lib/CMailFile.class.php b/htdocs/lib/CMailFile.class.php index d64dca0a14acc5dacec87e86b7e581254a6e2cba..85c02046480e2759e8e45dbbe468d0199a750301 100644 --- a/htdocs/lib/CMailFile.class.php +++ b/htdocs/lib/CMailFile.class.php @@ -24,7 +24,7 @@ /** * \file htdocs/lib/CMailFile.class.php - * \brief Fichier de la classe permettant d'envoyer des mail avec attachements + * \brief File of class to send emails (with attachments or not) * \version $Id$ * \author Dan Potter. * \author Eric Seigne @@ -33,7 +33,7 @@ /** * \class CMailFile - * \brief Classe d'envoi de mails et pieces jointes. Encapsule mail() avec d'eventuels attachements. + * \brief Class to send emails (with attachments or not) * \remarks Usage: $mailfile = new CMailFile($subject,$sendto,$replyto,$message,$filepath,$mimetype,$filename,$cc,$ccc,$deliveryreceipt,$msgishtml,$errors_to); * \remarks $mailfile->sendfile(); */ @@ -165,6 +165,9 @@ class CMailFile } } + // Add autocopy to + if (! empty($conf->global->MAIN_MAIL_AUTOCOPY_TO)) $addr_bcc.=($addr_bcc?', ':'').$conf->global->MAIN_MAIL_AUTOCOPY_TO; + // Action according to choosed sending method if ($conf->global->MAIN_MAIL_SENDMODE == 'mail') { diff --git a/htdocs/lib/functions.lib.php b/htdocs/lib/functions.lib.php index 73916db2846fd61d400b196fc4c01c409cf65879..f1ef768f73ce98512c3966786cf9b26bb99ffe5c 100644 --- a/htdocs/lib/functions.lib.php +++ b/htdocs/lib/functions.lib.php @@ -1512,7 +1512,7 @@ function img_mime($file,$alt='') /** * \brief Show information for admin users * \param text Text info - * \param infoonimgalt Info is shown on alt of star picto, otherwise it is show on output + * \param infoonimgalt Info is shown only on alt of star picto, otherwise it is show on output after the star picto * \return string String with info text */ function info_admin($texte,$infoonimgalt=0)