Bug 2458: Si on envoie un email depuis Linux ,
le return-path doit être spécifié
This commit is contained in:
parent
5334bec89d
commit
60bf53262e
5 changed files with 51 additions and 11 deletions
|
|
@ -42,10 +42,7 @@ class Sendmail extends Sendmail_Core
|
|||
{
|
||||
if ( $this->can_send() == false ) throw new Exception(_('Email non envoyé'),EMAIL_LIMIT);
|
||||
|
||||
if (!mail($this->mailto, $this->subject, $this->content,$this->header))
|
||||
{
|
||||
throw new Exception('send failed');
|
||||
}
|
||||
parent::send();
|
||||
// Increment email amount
|
||||
$repo =new Database();
|
||||
$date=date('Ymd');
|
||||
|
|
@ -167,7 +164,7 @@ class Sendmail extends Sendmail_Core
|
|||
array(1,$p_dossier,$p_date));
|
||||
return;
|
||||
} else {
|
||||
// update + sp_emaoun_email
|
||||
// update + amount of sent emails
|
||||
$p_repo->exec_sql("update dossier_sent_email set de_sent_email=de_sent_email+1 where dos_id=$1 and de_date=$2",
|
||||
array($p_dossier,$p_date));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -98,3 +98,6 @@ define ("DEBUGNOALYSS",0);
|
|||
// with NGINX it is needed to set the NOALYSS_URL , it is the default URL of
|
||||
// your installation, example with https://demo.noalyss.eu
|
||||
// define ("NOALYSS_URL","https://demo.noalyss.eu");
|
||||
// For POSTFIX, when sending email from NOALYSS via sendmail an extra parameter is needed
|
||||
// for the Return-Path, the FROM will be replaced by the Sendmail_Core->from value
|
||||
//define("MAIL_EXTRA_PARAM","-f [FROM]")
|
||||
|
|
|
|||
|
|
@ -452,7 +452,9 @@ function noalyss_class_autoloader($class)
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
if ( ! defined("MAIL_EXTRA_PARAM")) {
|
||||
define("MAIL_EXTRA_PARAM","-f [FROM]");
|
||||
}
|
||||
spl_autoload_register('\noalyss_class_autoloader', true);
|
||||
|
||||
require_once NOALYSS_BASE.'/vendor/autoload.php';
|
||||
|
|
|
|||
|
|
@ -305,6 +305,13 @@ function display_file_config($p_array, $from_setup = 1, $p_os = 1)
|
|||
// with NGINX it is needed to set the NOALYSS_URL , it is the default URL of $a
|
||||
// your installation, example with https://demo.noalyss.eu $a
|
||||
// define ("NOALYSS_URL","https://demo.noalyss.eu"); $a
|
||||
EOF;
|
||||
echo <<<EOF
|
||||
// $a
|
||||
// $a
|
||||
// For POSTFIX, when sending email from NOALYSS via sendmail an extra parameter is needed $a
|
||||
// for the Return-Path, the [FROM] will be replaced by the email of the sender (Sendmail_Core->from value)$a
|
||||
//define("MAIL_EXTRA_PARAM","-f [FROM]") $a
|
||||
EOF;
|
||||
}
|
||||
/*!
|
||||
|
|
|
|||
|
|
@ -46,9 +46,37 @@ class Sendmail_Core
|
|||
protected $content;
|
||||
protected $header;
|
||||
protected $format;
|
||||
|
||||
protected $supplemental_header; //!< $supplemental_header(string) supplemental header to add
|
||||
protected $supplemental_param; //!< $supplemental_param (string) 5th parameter for mail()
|
||||
// for postfix, it should be "-f {$this->from}" for the Return-Path
|
||||
|
||||
function __construct()
|
||||
{
|
||||
$this->format='PLAIN';
|
||||
$this->supplemental_header="";
|
||||
$this->supplemental_param=MAIL_EXTRA_PARAM;
|
||||
}
|
||||
public function getSupplemental_param()
|
||||
{
|
||||
return $this->supplemental_param;
|
||||
}
|
||||
|
||||
public function setSupplemental_param($supplemental_param)
|
||||
{
|
||||
$this->supplemental_param = $supplemental_param;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getSupplemental_header()
|
||||
{
|
||||
return $this->supplemental_header;
|
||||
}
|
||||
|
||||
public function setSupplemental_header($supplemental_header)
|
||||
{
|
||||
$this->supplemental_header = $supplemental_header;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function get_format() {
|
||||
|
|
@ -137,7 +165,7 @@ class Sendmail_Core
|
|||
*/
|
||||
function add_supplemental_header()
|
||||
{
|
||||
return '';
|
||||
return $this->supplemental_header;
|
||||
}
|
||||
/**
|
||||
*@brief create the message before sending
|
||||
|
|
@ -156,6 +184,7 @@ class Sendmail_Core
|
|||
|
||||
// main header (multipart mandatory)
|
||||
$this->header = "From: " . $this->from . $eol;
|
||||
$this->header .= "Reply-To: " . $this->from . $eol;
|
||||
$this->header .= "MIME-Version: 1.0" . $eol;
|
||||
$this->header .= $this->add_supplemental_header();
|
||||
if ($this->format == 'PLAIN')
|
||||
|
|
@ -232,6 +261,7 @@ eof;
|
|||
if ( empty ($this->afile) ) $this->content.=$eol;
|
||||
|
||||
$this->content .= "--" . $separator . "--";
|
||||
$this->supplemental_param= str_replace("[FROM]", $this->from, $this->supplemental_param);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -246,8 +276,9 @@ eof;
|
|||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
$encoded_subject = mb_encode_mimeheader( $this->subject, 'UTF-8', 'B');
|
||||
|
||||
if (!mail($this->mailto, $this->subject, $this->content,$this->header))
|
||||
if (!mail($this->mailto,$encoded_subject, $this->content,$this->header,$this->supplemental_param))
|
||||
{
|
||||
throw new Exception('send failed');
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue