- LSmail : Ajout du paramètre $headers à la méthode sendMail()

- LSsession_recoverPassword : Utilisation de LSaddon::mail plutôt que de la 
	commande mail() directement.
This commit is contained in:
Benjamin Renard 2008-10-14 16:21:36 +00:00
parent c8badaaa6c
commit 6710a1a51f
2 changed files with 93 additions and 95 deletions

View file

@ -130,16 +130,15 @@
*
* @retval boolean true si MAIL est pleinement supporté, false sinon
*/
function sendMail($to,$subject,$msg) {
function sendMail($to,$subject,$msg,$headers=array()) {
$mail_obj = & Mail::factory(MAIL_SEND_METHOD, $MAIL_SEND_PARAMS);
if(is_array($MAIL_HEARDERS)) {
$headers = $MAIL_HEARDERS;
}
else {
$headers = array();
$headers = array_merge($headers,$MAIL_HEARDERS);
}
if ($subject) {
$headers["Subject"] = $subject;
}
if (!isset($headers['From']) && ($GLOBALS['LSsession'] -> getEmailSender() != "")) {
$headers['From'] = $GLOBALS['LSsession'] -> getEmailSender();
}

View file

@ -329,18 +329,16 @@ class LSsession {
if (isset($_GET['LSsession_recoverPassword'])) {
LSdebug('Recover : Id trouvé');
if ($this -> ldapServer['recoverPassword']) {
if ($this -> loadLSaddon('mail')) {
LSdebug('Récupération active');
$user=$result[0];
$emailAddress = $user -> getValue($this -> ldapServer['recoverPassword']['mailAttr']);
$emailAddress = $emailAddress[0];
// Header des mails
$headers="Content-Type: text/plain; charset=UTF-8; format=flowed";
$sendParams=array();
if ($this -> ldapServer['recoverPassword']['recoveryEmailSender']) {
$headers.="\nFrom: ".$this -> ldapServer['recoverPassword']['recoveryEmailSender'];
}
else if($this -> getEmailSender()) {
$headers.="\nFrom: ".$this -> getEmailSender();
$sendParams['From']=$this -> ldapServer['recoverPassword']['recoveryEmailSender'];
}
if (checkEmail($emailAddress)) {
@ -373,11 +371,11 @@ class LSsession {
$recovery_url .= $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'].'&recoveryHash='.$recovery_hash;
if (
mail(
sendMail(
$emailAddress,
$this -> ldapServer['recoverPassword']['recoveryHashMail']['subject'],
getFData($this -> ldapServer['recoverPassword']['recoveryHashMail']['msg'],$recovery_url),
$headers
$sendParams
)
){
// Mail a bien été envoyé
@ -418,11 +416,11 @@ class LSsession {
if($lostPasswdForm -> validate()) {
if ($user -> updateData('lostPassword')) {
if (
mail(
sendMail(
$emailAddress,
$this -> ldapServer['recoverPassword']['newPasswordMail']['subject'],
getFData($this -> ldapServer['recoverPassword']['newPasswordMail']['msg'],$mdp),
$headers
$sendParams
)
){
// Mail a bien été envoyé
@ -457,6 +455,7 @@ class LSsession {
$GLOBALS['LSerror'] -> addErrorCode(1019);
}
}
}
else {
$GLOBALS['LSerror'] -> addErrorCode(1018);
}