Beispiel #1
0
 /**
  * method to retrieve the a mailer instance
  * 
  * @return Billrun_Db
  */
 public static function mailer()
 {
     if (!isset(self::$mailer)) {
         try {
             self::$mailer = new Zend_Mail();
             //TODO set common configuration.
             $fromName = Billrun_Factory::config()->getConfigValue('mailer.from.address', 'no-reply');
             $fromAddress = Billrun_Factory::config()->getConfigValue('mailer.from.name', 'Billrun');
             self::$mailer->setFrom($fromName, $fromAddress);
             //$mail->setDefaultTransport($transport);
         } catch (Exception $e) {
             self::log("Can't instantiat mail object. Please check your settings", Zend_Log::ALERT);
             return false;
         }
     }
     return self::$mailer;
 }
Beispiel #2
0
 public static function sendMail($subject, $body, $recipients, $attachments = array())
 {
     $mailer = Billrun_Factory::mailer()->setSubject($subject)->setBodyText($body);
     //add attachments
     foreach ($attachments as $attachment) {
         $mailer->addAttachment($attachment);
     }
     //set recipents
     foreach ($recipients as $recipient) {
         $mailer->addTo($recipient);
     }
     //sen email
     return $mailer->send();
 }