diff --git a/htdocs/admin/mails.php b/htdocs/admin/mails.php
index ff0fb329c5c..6de2835a4f2 100644
--- a/htdocs/admin/mails.php
+++ b/htdocs/admin/mails.php
@@ -68,7 +68,8 @@ if ($_POST["action"] == 'send' && ! $_POST["cancel"])
$filename = array();
$email_from = $conf->global->MAIN_MAIL_EMAIL_FROM;
- $sendto = $_POST["sendto"];
+ $errors_to = $_POST["errorstomail"];
+ $sendto = $_POST["sendto"];
$subject = $_POST['subject'];
$body = $_POST['message'];
if ($_FILES['addedfile']['tmp_name'])
@@ -97,9 +98,9 @@ if ($_POST["action"] == 'send' && ! $_POST["cancel"])
$mailfile = new CMailFile($subject,$sendto,$email_from,$body,
$filepath,$mimetype,$filename,
- '', '', 0, $msgishtml);
-
- $result=$mailfile->sendfile();
+ '', '', 0, $msgishtml,$errors_to);
+
+ $result=$mailfile->sendfile();
if ($result)
{
$message='
'.$langs->trans("MailSuccessfulySent",$email_from,$sendto).'
';
@@ -206,6 +207,7 @@ else
$formmail->frommail = $conf->global->MAIN_MAIL_EMAIL_FROM;
$formmail->withsubstit=0;
$formmail->withfrom=1;
+ $formmail->witherrorsto=1;
$formmail->withto=$user->email?$user->email:1;
$formmail->withcc=0;
$formmail->withtopic=$langs->trans("Test");
diff --git a/htdocs/compta/prelevement/rejet-prelevement.class.php b/htdocs/compta/prelevement/rejet-prelevement.class.php
index f778ba21d17..7440aed104a 100644
--- a/htdocs/compta/prelevement/rejet-prelevement.class.php
+++ b/htdocs/compta/prelevement/rejet-prelevement.class.php
@@ -211,8 +211,7 @@ class RejetPrelevement
$mailfile = new CMailFile($subject,$sendto,$from,$message,
$arr_file,$arr_mime,$arr_name,
- '', '', 0, $msgishtml);
- $mailfile->errors_to = $this->user->email;
+ '', '', 0, $msgishtml,$this->user->email);
$result=$mailfile->sendfile();
if ($result)
diff --git a/htdocs/html.formmail.class.php b/htdocs/html.formmail.class.php
index cd870b39948..116c2fa7df1 100644
--- a/htdocs/html.formmail.class.php
+++ b/htdocs/html.formmail.class.php
@@ -1,5 +1,5 @@
+/* Copyright (C) 2005-2007 Laurent Destailleur
*
* 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
@@ -80,6 +80,7 @@ class FormMail
$this->withfrom=1;
$this->withto=1;
$this->withtocc=1;
+ $this->witherrorsto=0;
$this->withtopic=1;
$this->withfile=0;
$this->withbody=1;
@@ -88,6 +89,7 @@ class FormMail
$this->withreplytoreadonly=1;
$this->withtoreadonly=0;
$this->withtoccreadonly=0;
+ $this->witherrorstoreadonly=0;
$this->withtopicreadonly=0;
$this->withbodyreadonly=0;
$this->withdeliveryreceiptreadonly=0;
@@ -152,7 +154,26 @@ class FormMail
print "\n";
}
}
-
+
+ // Errorsto
+ if ($this->witherrorsto)
+ {
+ //if (! $this->errorstomail) $this->errorstomail=$this->frommail;
+ if ($this->witherrorstoreadonly)
+ {
+ print '';
+ print "| ".$langs->trans("MailErrorsTo")." | ";
+ print $this->errorstomail;
+ print " |
\n";
+ }
+ else
+ {
+ print "| ".$langs->trans("MailErrorsTo")." | ";
+ print "errorstomail."\">";
+ print " |
\n";
+ }
+ }
+
// To
if ($this->withto || is_array($this->withto))
{
diff --git a/htdocs/langs/en_US/mails.lang b/htdocs/langs/en_US/mails.lang
index cceff40f1f5..2579b042874 100644
--- a/htdocs/langs/en_US/mails.lang
+++ b/htdocs/langs/en_US/mails.lang
@@ -9,6 +9,7 @@ MailRecipients=Recipients
MailRecipient=Recipient
MailTitle=Title
MailFrom=Sender
+MailErrorsTo=Errors to
MailReply=Reply to
MailTo=Receiver(s)
MailCC=Copy to
diff --git a/htdocs/langs/fr_FR/mails.lang b/htdocs/langs/fr_FR/mails.lang
index ff97e9f33c4..87c9376030a 100644
--- a/htdocs/langs/fr_FR/mails.lang
+++ b/htdocs/langs/fr_FR/mails.lang
@@ -9,6 +9,7 @@ MailRecipients=Destinataires
MailRecipient=Destinataire
MailTitle=Titre
MailFrom=Émetteur
+MailErrorsTo=Erreurs à
MailReply=Réponse à
MailTo=Destinataire(s)
MailCC=Copie à
diff --git a/htdocs/lib/CMailFile.class.php b/htdocs/lib/CMailFile.class.php
index f281ac8d819..fcef4fdff4a 100644
--- a/htdocs/lib/CMailFile.class.php
+++ b/htdocs/lib/CMailFile.class.php
@@ -48,9 +48,11 @@ class CMailFile
{
var $subject;
var $addr_from;
- var $addr_to;
+ var $errors_to;
+ var $addr_to;
var $addr_cc;
var $addr_bcc;
+
var $mime_boundary;
var $deliveryreceipt;
@@ -75,9 +77,9 @@ class CMailFile
*/
function CMailFile($subject,$to,$from,$msg,
$filename_list=array(),$mimetype_list=array(),$mimefilename_list=array(),
- $addr_cc="",$addr_bcc="",$deliveryreceipt=0,$msgishtml=0)
+ $addr_cc="",$addr_bcc="",$deliveryreceipt=0,$msgishtml=0, $errors_to='')
{
- dolibarr_syslog("CMailFile::CMailfile: from=$from, to=$to, addr_cc=$addr_cc, addr_bcc=$addr_bcc");
+ dolibarr_syslog("CMailFile::CMailfile: from=$from, to=$to, addr_cc=$addr_cc, addr_bcc=$addr_bcc, errors_to=$errors_to");
dolibarr_syslog("CMailFile::CMailfile: subject=$subject, deliveryreceipt=$deliveryreceipt, msgishtml=$msgishtml");
foreach ($filename_list as $i => $val)
{
@@ -107,6 +109,7 @@ class CMailFile
// En-tete dans $smtp_headers
$this->subject = $subject;
$this->addr_from = $from;
+ $this->errors_to = $errors_to;
$this->addr_to = $to;
$this->addr_cc = $addr_cc;
$this->addr_bcc = $addr_bcc;
@@ -172,7 +175,7 @@ class CMailFile
{
global $conf;
- dolibarr_syslog("CMailFile::sendfile addr_from=".$this->addr_from.", addr_to=".$this->addr_to.", subject=".$this->subject);
+ dolibarr_syslog("CMailFile::sendfile addr_to=".$this->addr_to.", subject=".$this->subject);
dolibarr_syslog("CMailFile::sendfile header=\n".$this->headers);
//dolibarr_syslog("CMailFile::sendfile message=\n".$message);
//$this->send_to_file();
@@ -205,6 +208,7 @@ class CMailFile
}
else
{
+ /* Le errors_to doit se gerer dans en-tete http et non par option -f
if ($this->errors_to)
{
// \TODO Tester que le safe_mode est inactif car fonction mail avec ces param non dispo en safe_mode
@@ -212,11 +216,11 @@ class CMailFile
$res = mail($dest,$this->subject,stripslashes($this->message),$this->headers,"-f".getValidAddress($this->errors_to,2));
}
else
- {
+ {*/
dolibarr_syslog("CMailFile::sendfile: mail start SMTP=".ini_get('SMTP').", PORT=".ini_get('smtp_port'));
//dolibarr_syslog("to=".getValidAddress($this->addr_to,2).", subject=".$this->subject.", message=".stripslashes($this->message).", header=".$this->headers);
$res = mail($dest,$this->subject,stripslashes($this->message),$this->headers);
- }
+ /* } */
if (! $res)
{
$this->error="Failed to send mail to SMTP=".ini_get('SMTP').", PORT=".ini_get('smtp_port')."
Check your server logs and your firewalls setup";