mirror of
https://gitlab.easter-eggs.com/ee/ldapsaisie.git
synced 2024-11-23 02:19:07 +01:00
- 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:
parent
c8badaaa6c
commit
6710a1a51f
2 changed files with 93 additions and 95 deletions
|
@ -130,16 +130,15 @@
|
||||||
*
|
*
|
||||||
* @retval boolean true si MAIL est pleinement supporté, false sinon
|
* @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);
|
$mail_obj = & Mail::factory(MAIL_SEND_METHOD, $MAIL_SEND_PARAMS);
|
||||||
|
|
||||||
if(is_array($MAIL_HEARDERS)) {
|
if(is_array($MAIL_HEARDERS)) {
|
||||||
$headers = $MAIL_HEARDERS;
|
$headers = array_merge($headers,$MAIL_HEARDERS);
|
||||||
}
|
|
||||||
else {
|
|
||||||
$headers = array();
|
|
||||||
}
|
}
|
||||||
|
if ($subject) {
|
||||||
$headers["Subject"] = $subject;
|
$headers["Subject"] = $subject;
|
||||||
|
}
|
||||||
if (!isset($headers['From']) && ($GLOBALS['LSsession'] -> getEmailSender() != "")) {
|
if (!isset($headers['From']) && ($GLOBALS['LSsession'] -> getEmailSender() != "")) {
|
||||||
$headers['From'] = $GLOBALS['LSsession'] -> getEmailSender();
|
$headers['From'] = $GLOBALS['LSsession'] -> getEmailSender();
|
||||||
}
|
}
|
||||||
|
|
|
@ -329,18 +329,16 @@ class LSsession {
|
||||||
if (isset($_GET['LSsession_recoverPassword'])) {
|
if (isset($_GET['LSsession_recoverPassword'])) {
|
||||||
LSdebug('Recover : Id trouvé');
|
LSdebug('Recover : Id trouvé');
|
||||||
if ($this -> ldapServer['recoverPassword']) {
|
if ($this -> ldapServer['recoverPassword']) {
|
||||||
|
if ($this -> loadLSaddon('mail')) {
|
||||||
LSdebug('Récupération active');
|
LSdebug('Récupération active');
|
||||||
$user=$result[0];
|
$user=$result[0];
|
||||||
$emailAddress = $user -> getValue($this -> ldapServer['recoverPassword']['mailAttr']);
|
$emailAddress = $user -> getValue($this -> ldapServer['recoverPassword']['mailAttr']);
|
||||||
$emailAddress = $emailAddress[0];
|
$emailAddress = $emailAddress[0];
|
||||||
|
|
||||||
// Header des mails
|
// Header des mails
|
||||||
$headers="Content-Type: text/plain; charset=UTF-8; format=flowed";
|
$sendParams=array();
|
||||||
if ($this -> ldapServer['recoverPassword']['recoveryEmailSender']) {
|
if ($this -> ldapServer['recoverPassword']['recoveryEmailSender']) {
|
||||||
$headers.="\nFrom: ".$this -> ldapServer['recoverPassword']['recoveryEmailSender'];
|
$sendParams['From']=$this -> ldapServer['recoverPassword']['recoveryEmailSender'];
|
||||||
}
|
|
||||||
else if($this -> getEmailSender()) {
|
|
||||||
$headers.="\nFrom: ".$this -> getEmailSender();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (checkEmail($emailAddress)) {
|
if (checkEmail($emailAddress)) {
|
||||||
|
@ -373,11 +371,11 @@ class LSsession {
|
||||||
$recovery_url .= $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'].'&recoveryHash='.$recovery_hash;
|
$recovery_url .= $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'].'&recoveryHash='.$recovery_hash;
|
||||||
|
|
||||||
if (
|
if (
|
||||||
mail(
|
sendMail(
|
||||||
$emailAddress,
|
$emailAddress,
|
||||||
$this -> ldapServer['recoverPassword']['recoveryHashMail']['subject'],
|
$this -> ldapServer['recoverPassword']['recoveryHashMail']['subject'],
|
||||||
getFData($this -> ldapServer['recoverPassword']['recoveryHashMail']['msg'],$recovery_url),
|
getFData($this -> ldapServer['recoverPassword']['recoveryHashMail']['msg'],$recovery_url),
|
||||||
$headers
|
$sendParams
|
||||||
)
|
)
|
||||||
){
|
){
|
||||||
// Mail a bien été envoyé
|
// Mail a bien été envoyé
|
||||||
|
@ -418,11 +416,11 @@ class LSsession {
|
||||||
if($lostPasswdForm -> validate()) {
|
if($lostPasswdForm -> validate()) {
|
||||||
if ($user -> updateData('lostPassword')) {
|
if ($user -> updateData('lostPassword')) {
|
||||||
if (
|
if (
|
||||||
mail(
|
sendMail(
|
||||||
$emailAddress,
|
$emailAddress,
|
||||||
$this -> ldapServer['recoverPassword']['newPasswordMail']['subject'],
|
$this -> ldapServer['recoverPassword']['newPasswordMail']['subject'],
|
||||||
getFData($this -> ldapServer['recoverPassword']['newPasswordMail']['msg'],$mdp),
|
getFData($this -> ldapServer['recoverPassword']['newPasswordMail']['msg'],$mdp),
|
||||||
$headers
|
$sendParams
|
||||||
)
|
)
|
||||||
){
|
){
|
||||||
// Mail a bien été envoyé
|
// Mail a bien été envoyé
|
||||||
|
@ -457,6 +455,7 @@ class LSsession {
|
||||||
$GLOBALS['LSerror'] -> addErrorCode(1019);
|
$GLOBALS['LSerror'] -> addErrorCode(1019);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
$GLOBALS['LSerror'] -> addErrorCode(1018);
|
$GLOBALS['LSerror'] -> addErrorCode(1018);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue