{"action":"created","issue":{"url":"https://api.github.com/repos/PHPMailer/PHPMailer/issues/541","labels_url":"https://api.github.com/repos/PHPMailer/PHPMailer/issues/541/labels{/name}","comments_url":"https://api.github.com/repos/PHPMailer/PHPMailer/issues/541/comments","events_url":"https://api.github.com/repos/PHPMailer/PHPMailer/issues/541/events","html_url":"https://github.com/PHPMailer/PHPMailer/issues/541","id":113302695,"number":541,"title":"Maximum execution time of 0 seconds exceeded","user":{"login":"resident-uhlig","id":1163606,"avatar_url":"https://avatars.githubusercontent.com/u/1163606?v=3","gravatar_id":"","url":"https://api.github.com/users/resident-uhlig","html_url":"https://github.com/resident-uhlig","followers_url":"https://api.github.com/users/resident-uhlig/followers","following_url":"https://api.github.com/users/resident-uhlig/following{/other_user}","gists_url":"https://api.github.com/users/resident-uhlig/gists{/gist_id}","starred_url":"https://api.github.com/users/resident-uhlig/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/resident-uhlig/subscriptions","organizations_url":"https://api.github.com/users/resident-uhlig/orgs","repos_url":"https://api.github.com/users/resident-uhlig/repos","events_url":"https://api.github.com/users/resident-uhlig/events{/privacy}","received_events_url":"https://api.github.com/users/resident-uhlig/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-10-26T08:00:54Z","updated_at":"2015-10-26T08:41:37Z","closed_at":null,"body":"Sending our newsletter to 12713 recipients always fails after a little over 11k recipients.\r\n\r\n```log\r\n[10-Jun-2015 14:19:18 UTC] PHP Fatal error:  Maximum execution time of 0 seconds exceeded in /var/www/PHPMailer/class.smtp.php on line 526\r\n[10-Jun-2015 14:31:33 UTC] PHP Fatal error:  Maximum execution time of 0 seconds exceeded in /var/www/PHPMailer/class.smtp.php on line 553\r\n[10-Jun-2015 14:43:50 UTC] PHP Fatal error:  Maximum execution time of 0 seconds exceeded in /var/www/PHPMailer/class.smtp.php on line 521\r\n[09-Jul-2015 08:34:57 UTC] PHP Fatal error:  Maximum execution time of 0 seconds exceeded in /var/www/PHPMailer/class.smtp.php on line 556\r\n[02-Sep-2015 07:14:31 UTC] PHP Fatal error:  Maximum execution time of 0 seconds exceeded in /var/www/PHPMailer/class.smtp.php on line 556\r\n[26-Oct-2015 07:07:37 UTC] PHP Fatal error:  Maximum execution time of 0 seconds exceeded in /var/www/PHPMailer/class.smtp.php on line 506\r\n```\r\n\r\nI wouldn't bother you if it happened outside of that file. But as you can see the error always happens inside of class.smtp.php of PHPMailer.\r\n\r\nI noticed that all those lines belong to the method `SMTP::data($msg_data)`.\r\n\r\nBefore PHPMailer calls `$this->smtp->data($header . $body)` it calls `$this->smtp->connect(...)`. Inside of that function `SMTP::connect(...)` there is [some kind of timeout handling](https://github.com/PHPMailer/PHPMailer/blob/master/class.smtp.php#L316). Maybe this is the reason for the PHP error. Do you think the same and can you think of a solution?\r\n\r\nIn our sending script we do `set_time_limit(0)` before creating the PHPMailer instance. We use one instance of PHPMailer only. However we clear and reset the recipient for each e-mail address.\r\n\r\ne.g. (pseudo code)\r\n```php\r\n$mail = new PHPMailer();\r\n// ... (setting hostname, smtp, from etc.)\r\nforeach($recipients as $addr) {\r\n  $mail->ClearAddresses();\r\n  $mail->AddAddress($addr);\r\n  $mail->Send();\r\n  // ... logging result of Send() to a plain text file\r\n  $mail->ClearAddresses();\r\n}\r\n```\r\n\r\nPHP: 5.6.14\r\nPHPMailer: 5.2.8 (I doubt that upgrading would help in this case)\r\nOS: RHEL\r\n"},"comment":{"url":"https://api.github.com/repos/PHPMailer/PHPMailer/issues/comments/151060879","html_url":"https://github.com/PHPMailer/PHPMailer/issues/541#issuecomment-151060879","issue_url":"https://api.github.com/repos/PHPMailer/PHPMailer/issues/541","id":151060879,"user":{"login":"resident-uhlig","id":1163606,"avatar_url":"https://avatars.githubusercontent.com/u/1163606?v=3","gravatar_id":"","url":"https://api.github.com/users/resident-uhlig","html_url":"https://github.com/resident-uhlig","followers_url":"https://api.github.com/users/resident-uhlig/followers","following_url":"https://api.github.com/users/resident-uhlig/following{/other_user}","gists_url":"https://api.github.com/users/resident-uhlig/gists{/gist_id}","starred_url":"https://api.github.com/users/resident-uhlig/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/resident-uhlig/subscriptions","organizations_url":"https://api.github.com/users/resident-uhlig/orgs","repos_url":"https://api.github.com/users/resident-uhlig/repos","events_url":"https://api.github.com/users/resident-uhlig/events{/privacy}","received_events_url":"https://api.github.com/users/resident-uhlig/received_events","type":"User","site_admin":false},"created_at":"2015-10-26T08:41:37Z","updated_at":"2015-10-26T08:41:37Z","body":"@Synchro \r\n> I think timeout handling changed in 5.2.9, so upgrading might help, and you should anyway.\r\n\r\nAfter a [quick comparison](https://github.com/PHPMailer/PHPMailer/compare/d3802c597bff8f6c2ccfa3eab2a511aa01b8d68f...master#diff-ac5c95a7c256b389656048bd46dc2985L244) of the current and the 5.2.8 class.smtp.php the code around set_time_limit() looks very similar to me.\r\n\r\n> For a template of how to send efficiently, look at the mailing list example in the examples folder.\r\n\r\nIs [this](https://github.com/PHPMailer/PHPMailer/blob/master/examples/mailing_list.phps) the example? I think that's about the way we do it already.\r\n\r\nAnd you are right, it is not CLI but a web page. The reason was that a user should be able to trigger the sending on a web page. Yes, there are ways to do it as CLI anyway and maybe we will change to a CLI after all.\r\n\r\nI still think this error should not occur with the current code and setup.\r\n"}}