Michael RICOIS 935d4cc543 debugLog
2016-07-13 16:20:51 +02:00

49 lines
1.4 KiB
PHP

<?php
class Metier_Util_Mail
{
/**
* Envoi email
* @param string $from
* @param string $to
* @param string $subject
* @param string $text
* @param string $html
* @param array $tabAttachedFiles
*/
function send($from, $to, $subject, $text='', $html='', $tabAttachedFiles=array())
{
$to = preg_split("/[\s,;]+/", $to);
$mail = new Scores_Mail_Method();
$mail->setFrom($from);
if ( count($to) > 0 ) {
foreach ( $to as $item ) {
$mail->addTo($item);
}
}
$mail->setSubject($subject);
if ($text!='') {
$mail->setBodyText($text);
}
if ($html!='') {
$mail->setBodyHtml($html);
}
if ( count($tabAttachedFiles) > 0 ) {
foreach ($tabAttachedFiles as $file) {
$at = new Zend_Mime_Part( file_get_contents( $file ) );
$mail->addAttachment($at);
}
}
try {
$mail->execute();
} catch (Zend_Mail_Transport_Exception $e) {
file_put_contents(LOG_PATH.'/sendMailError.log', date('Y-m-d H:i:s')." - ".$e->getMessage()."\n", FILE_APPEND);
} catch (Zend_Mail_Protocol_Exception $e) {
file_put_contents(LOG_PATH.'/sendMailError.log', date('Y-m-d H:i:s')." - ".$e->getMessage()."\n", FILE_APPEND);
}
}
}