/** * Send message or put it queue if necessary */ public function send(Zend_Mail $mail) { if (!$mail instanceof Am_Mail) { trigger_error(__METHOD__ . ' should get Am_Mail, not Zend_Mail', E_USER_NOTICE); $isInstant = true; } else { $isInstant = $mail->isInstant(); } $status = $this->getQueueStatus(); $sent = null; $exception = null; if (in_array($status, array(self::QUEUE_DISABLED, self::QUEUE_OK)) || $status == self::QUEUE_ONLY_INSTANT && $isInstant) { try { $this->transport->send($mail); $sent = Am_Di::getInstance()->time; // workaround for memory overusage if ($this->transport instanceof Zend_Mail_Transport_Smtp) { $this->transport->getConnection()->resetLog(); } // end of workaround } catch (Zend_Mail_Exception $e) { $exception = $e; } } if ($status != self::QUEUE_DISABLED || $this->logEnabled()) { $this->addToQueue($mail, $sent); } if ($exception) { throw $exception; } // re-raise }