ZF-8278: Out of memory on large sends

Issue Type: Improvement Created: 2009-11-10T07:11:59.000+0000 Last Updated: 2009-11-17T06:06:45.000+0000 Status: Resolved Fix version(s): - 1.10.0 (27/Jan/10)

Reporter: Luke Richards (lukerichards) Assignee: Satoru Yoshida (satoruyoshida) Tags: - Zend_Mail

Related issues: Attachments:


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:

<pre class="highlight">
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);


Posted by Fabio Napoleoni (fabio) on 2009-11-10T16:28:14.000+0000

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.

Posted by Satoru Yoshida (satoruyoshida) on 2009-11-14T05:32:56.000+0000

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.

Posted by Satoru Yoshida (satoruyoshida) on 2009-11-16T20:13:22.000+0000

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.

Have you found an issue?

See the Overview section for more details.


© 2006-2018 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.