Esempio n. 1
0
 public static function sendEmail($to, $body, $subject = "", $from = self::NO_REPLY_MAIL, $fromName = self::NO_REPLY_NAME, $replyTo = self::NO_REPLY_MAIL, $bcc = array(), $attachment = '')
 {
     $template_header = '';
     $template_footer = '';
     try {
         $mail = new sfMail();
         $mail->initialize();
         $mail->setMailer('sendmail');
         $mail->setCharset('utf-8');
         $mail->setContentType('text/html');
         $mail->setSender($from, $fromName);
         $mail->setFrom($from, $fromName);
         $mail->addReplyTo($replyTo);
         $mail->addAddress($to);
         if (is_array($attachment)) {
             foreach ($attachment as $key => $row) {
                 $mail->addAttachment($row);
             }
         } else {
             if ($attachment != '') {
                 $mail->addAttachment($attachment);
             }
         }
         foreach ($bcc as $bcc_address) {
             $mail->addBcc($bcc_address);
         }
         $mail->setSubject($subject);
         $mail->setBody($template_header . $body . $template_footer);
         $mail->send();
         return true;
     } catch (Exception $e) {
         return false;
     }
 }