It is necessary for several users to send a letter, the content of the letter is the result of the execution of the php script (for each entry the script is different, but sometimes the scripts are repeated).

foreach ($users as $key => $user) { ini_set('memory_limit', '-1'); ob_start(); include($user['file']); $content = ob_get_contents(); ob_end_clean(); mail($user['email'], $user['email_subject'], $message, $header); } 

Sending a letter with content $ content. Everything works well if you need to send 3 letters with scripts A, B, C, but if you need to send 3 letters with scripts A, B, B then he sends the first two letters when the queue reaches the second B, then it gives an error

 "PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 233832 bytes) in ..." 

Tell me how to solve the problem

    1 answer 1

     ini_set('memory_limit', '-1'); - я думаю это не нужно Вашему скрипту вообще. попробуйте установить в 0 
    • include also better change to include_once - Maksym Prus
    • one
      ob_start () and ob_end_clean () are also unclear why for your task - Maksym Prus