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); } } }