Skip to content
Snippets Groups Projects
Commit db15ab6c authored by Regis Houssin's avatar Regis Houssin
Browse files

Fix: add possibility to force mail errors-to to all mails sent

parent 1a664187
No related branches found
No related tags found
No related merge requests found
......@@ -20,7 +20,7 @@
/**
* \file htdocs/admin/mails.php
* \brief Page to setup emails sending
* \version $Id: mails.php,v 1.71 2011/07/09 05:28:41 hregis Exp $
* \version $Id: mails.php,v 1.72 2011/07/09 06:10:06 hregis Exp $
*/
require("../main.inc.php");
......@@ -63,6 +63,7 @@ if (isset($_POST["action"]) && $_POST["action"] == 'update' && empty($_POST["can
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_ERRORS_TO", $_POST["MAIN_MAIL_ERRORS_TO"],'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");
......@@ -467,6 +468,12 @@ if (isset($_GET["action"]) && $_GET["action"] == 'edit')
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>';
// From
$var=!$var;
print '<tr '.$bc[$var].'><td>'.$langs->trans("MAIN_MAIL_ERRORS_TO").'</td>';
print '<td><input class="flat" name="MAIN_MAIL_ERRORS_TO" size="32" value="' . $conf->global->MAIN_MAIL_ERRORS_TO;
print '"></td></tr>';
// Autocopy to
$var=!$var;
......@@ -567,6 +574,13 @@ else
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>';
// Errors To
$var=!$var;
print '<tr '.$bc[$var].'><td>'.$langs->trans("MAIN_MAIL_ERRORS_TO").'</td>';
print '<td>'.$conf->global->MAIN_MAIL_ERRORS_TO;
if (!empty($conf->global->MAIN_MAIL_ERRORS_TO) && ! isValidEmail($conf->global->MAIN_MAIL_ERRORS_TO)) print img_warning($langs->trans("ErrorBadEMail"));
print '</td></tr>';
// Autocopy to
$var=!$var;
......@@ -723,5 +737,5 @@ else
$db->close();
llxFooter('$Date: 2011/07/09 05:28:41 $ - $Revision: 1.71 $');
llxFooter('$Date: 2011/07/09 06:10:06 $ - $Revision: 1.72 $');
?>
......@@ -21,7 +21,7 @@
* \file htdocs/core/class/html.formmail.class.php
* \ingroup core
* \brief Fichier de la classe permettant la generation du formulaire html d'envoi de mail unitaire
* \version $Id: html.formmail.class.php,v 1.28 2011/07/07 15:54:03 simnandez Exp $
* \version $Id: html.formmail.class.php,v 1.29 2011/07/09 06:10:07 hregis Exp $
*/
require_once(DOL_DOCUMENT_ROOT ."/core/class/html.form.class.php");
......@@ -309,17 +309,18 @@ class FormMail
if ($this->witherrorsto)
{
//if (! $this->errorstomail) $this->errorstomail=$this->frommail;
$errorstomail = (! empty($conf->global->MAIN_MAIL_ERRORS_TO) ? $conf->global->MAIN_MAIL_ERRORS_TO : $this->errorstomail);
if ($this->witherrorstoreadonly)
{
$out.= '<input type="hidden" id="errorstomail" name="errorstomail" value="'.$this->errorstomail.'" />';
$out.= '<input type="hidden" id="errorstomail" name="errorstomail" value="'.$errorstomail.'" />';
$out.= '<tr><td>'.$langs->trans("MailErrorsTo").'</td><td>';
$out.= $this->errorstomail;
$out.= $errorstomail;
$out.= "</td></tr>\n";
}
else
{
$out.= '<tr><td>'.$langs->trans("MailErrorsTo").'</td><td>';
$out.= '<input size="30" id="errorstomail" name="errorstomail" value="'.$this->errorstomail.'" />';
$out.= '<input size="30" id="errorstomail" name="errorstomail" value="'.$errorstomail.'" />';
$out.= "</td></tr>\n";
}
}
......
......@@ -229,6 +229,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_ERRORS_TO=Sender e-mail used for error returns emails sent
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
......
......@@ -230,6 +230,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_ERRORS_TO=EMail utilisé pour les retours d'erreurs des mails envoyés
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
......
......@@ -25,7 +25,7 @@
/**
* \file htdocs/lib/CMailFile.class.php
* \brief File of class to send emails (with attachments or not)
* \version $Id: CMailFile.class.php,v 1.144 2011/07/08 17:33:00 hregis Exp $
* \version $Id: CMailFile.class.php,v 1.145 2011/07/09 06:10:04 hregis Exp $
* \author Dan Potter.
* \author Eric Seigne
* \author Laurent Destailleur.
......@@ -349,7 +349,7 @@ class CMailFile
// le return-path dans les header ne fonctionne pas avec tous les MTA
// Le passage par -f est donc possible si la constante MAIN_MAIL_ALLOW_SENDMAIL_F est definie.
// La variable definie pose des pb avec certains sendmail securisee (option -f refusee car dangereuse)
$bounce = $this->addr_from != '' ? '-f' . $this->addr_from : '';
$bounce = (! empty($conf->global->MAIN_MAIL_ERRORS_TO) ? '-f' . $conf->global->MAIN_MAIL_ERRORS_TO : ($this->addr_from != '' ? '-f' . $this->addr_from : '') );
}
$this->message=stripslashes($this->message);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment