2008-09-25 17:15:33 +02:00
|
|
|
<?php
|
|
|
|
/*******************************************************************************
|
|
|
|
* Copyright (C) 2007 Easter-eggs
|
|
|
|
* http://ldapsaisie.labs.libre-entreprise.org
|
|
|
|
*
|
|
|
|
* Author: See AUTHORS file in top-level directory.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License version 2
|
|
|
|
* as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
|
|
|
|
******************************************************************************/
|
|
|
|
|
2009-01-12 11:57:27 +01:00
|
|
|
// Messages d'erreur
|
|
|
|
|
|
|
|
// Support
|
2009-01-25 15:37:03 +01:00
|
|
|
LSerror :: defineError('MAIL_SUPPORT_01',
|
2009-02-14 00:06:58 +01:00
|
|
|
_("MAIL Support : Pear::MAIL is missing.")
|
2009-01-12 11:57:27 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
// Autres erreurs
|
2009-01-25 15:37:03 +01:00
|
|
|
LSerror :: defineError('MAIL_00',
|
|
|
|
_("MAIL Error : %{msg}")
|
2009-01-12 11:57:27 +01:00
|
|
|
);
|
|
|
|
|
2009-01-25 15:37:03 +01:00
|
|
|
LSerror :: defineError('MAIL_01',
|
2009-03-15 22:06:18 +01:00
|
|
|
_("MAIL : Error sending your email")
|
2009-01-12 11:57:27 +01:00
|
|
|
);
|
2008-09-25 17:15:33 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Verification du support MAIL par ldapSaisie
|
|
|
|
*
|
|
|
|
* @author Benjamin Renard <brenard@easter-eggs.com>
|
|
|
|
*
|
|
|
|
* @retval boolean true si MAIL est pleinement supporté, false sinon
|
|
|
|
*/
|
|
|
|
function LSaddon_mail_support() {
|
|
|
|
$retval=true;
|
|
|
|
|
|
|
|
// Dependance de librairie
|
|
|
|
if (!class_exists('Mail')) {
|
2009-01-21 18:08:09 +01:00
|
|
|
if(!LSsession::includeFile(PEAR_MAIL)) {
|
2009-01-24 18:45:14 +01:00
|
|
|
LSerror :: addErrorCode('MAIL_SUPPORT_01');
|
2008-09-25 17:15:33 +02:00
|
|
|
$retval=false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return $retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Envoie d'un mail
|
|
|
|
*
|
|
|
|
* @author Benjamin Renard <brenard@easter-eggs.com>
|
|
|
|
*
|
|
|
|
* @retval boolean true si MAIL est pleinement supporté, false sinon
|
|
|
|
*/
|
2008-10-14 18:21:36 +02:00
|
|
|
function sendMail($to,$subject,$msg,$headers=array()) {
|
2008-09-25 17:15:33 +02:00
|
|
|
$mail_obj = & Mail::factory(MAIL_SEND_METHOD, $MAIL_SEND_PARAMS);
|
|
|
|
|
|
|
|
if(is_array($MAIL_HEARDERS)) {
|
2008-10-14 18:21:36 +02:00
|
|
|
$headers = array_merge($headers,$MAIL_HEARDERS);
|
2008-09-25 17:15:33 +02:00
|
|
|
}
|
2008-10-14 18:21:36 +02:00
|
|
|
if ($subject) {
|
|
|
|
$headers["Subject"] = $subject;
|
2008-09-25 17:15:33 +02:00
|
|
|
}
|
2009-01-24 18:45:14 +01:00
|
|
|
if (!isset($headers['From']) && (LSsession :: getEmailSender() != "")) {
|
|
|
|
$headers['From'] = LSsession :: getEmailSender();
|
2008-09-25 17:15:33 +02:00
|
|
|
}
|
2008-10-31 13:12:31 +01:00
|
|
|
$headers["To"] = $to;
|
2012-09-07 13:33:57 +02:00
|
|
|
|
|
|
|
$to = array (
|
|
|
|
'To' => $to
|
|
|
|
);
|
|
|
|
|
|
|
|
foreach(array_keys($headers) as $header) {
|
|
|
|
if(strtoupper($header) == 'BCC') {
|
|
|
|
$to['BCC'] = $headers[$header];
|
|
|
|
}
|
|
|
|
elseif(strtoupper($header) == 'CC') {
|
|
|
|
$to['CC'] = $headers[$header];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-09-25 17:15:33 +02:00
|
|
|
$ret = $mail_obj -> send($to,$headers,$msg);
|
|
|
|
|
|
|
|
if ($ret instanceof PEAR_Error) {
|
2009-01-24 18:45:14 +01:00
|
|
|
LSerror :: addErrorCode('MAIL_01');
|
|
|
|
LSerror :: addErrorCode('MAIL_00',$ret -> getMessage());
|
2008-09-25 17:15:33 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
2009-01-24 18:45:14 +01:00
|
|
|
?>
|