I have a simple php script that sends emails using PMTA
set_time_limit(0);
if ($socket = fsockopen("_IP_",2025,$errno, $errstr, 15)) {
fwrite($socket, "EHLO $ehlo\r\n");
foreach ($emails as $key => $email) {
fwrite($socket, "MAIL FROM: $from\r\n");
fwrite($socket, "RCPT TO: $email\r\n");
fwrite($socket, "DATA\r\n");
fwrite($socket, implode("\r\n", $headers)."\r\n\r\n".$body."\r\n");
fwrite($socket, ".\r\n");
}
fwrite($socket, "QUIT\r\n");
fclose($socket);
}
after around 3000 email fwrite will return with a warning Resource temporarily unavailable
PHP Notice: fwrite(): send of 187 bytes failed with errno=11 Resource temporarily unavailable in /var/www/html/app/send.php on line 340
Any ideas, where the problem is? Thanks!
errno=11 is socket report EAGAIN error that on nonblock pipes TCP buffer fully. The error handler should catch the EAGAIN error (errno=11), so any debugging assistance you. See PHP - error when using socket_recv