ZF-8278: Out of memory on large sends


When sending large amounts of email using the Zend_Mail_Transport_Protocol classes it causes an out of memory problem. This is because each time the protected send method is called it attaches the request to the end of the log. In cases when a lot of emails are being sent this grows eventually causing the memory limit error.

I'm not sure this is the correct solution but I fixed it by resetting the log every time the send method is called:

class Yourlibrary_Mail_Transport_Smtp extends Zend_Mail_Transport_Smtp
     * Send a mail using this transport
     * @param  Zend_Mail $mail
     * @access public
     * @return void
     * @throws Zend_Mail_Transport_Exception if mail is empty
    public function send(Zend_Mail $mail)
        $connection = $this->getConnection();
        if ($connection instanceof Zend_Mail_Protocol_Smtp) {
        return parent::send($mail);


In my case the patch work, I send a small list of about 800 members and without this class my script crashes unless I raise memory limit up to 256M or even 512M.

But with this class the problem is gone.

I think notation would be helpful. The notation in document should notice in case user send many mails.

So, I change this issue to Docs: Improvement.

I added limitation of log counts at SVN r19008 (trunk).

I will be happy if you would try new code ;-) This improvement would be released at 1.10.0 or later.