Linux – Sporadic “sendmail: fatal:” error when running mailer script

centoslinuxpostfixweb-server

I'm having bother trying to debug an occasional issue on my site. I run a PHP mailer script via the CLI to send mail to a few thousand addresses in batches. Occasionally, I get the following error before all emails have been sent:

sendmail: fatal: No recipient addresses found in message header
postdrop: warning: stdin: unexpected EOF in data, record type 78 length 276
postdrop: fatal: uid=10003: malformed input

This only happens from time to time. I'm on a Centos 5 server. Can anyone point me in the right direction for what could be happening here?

Best Answer

It looks as if you pipe your mails through the sendmail program of Postfix. But when your error occurs then the data stream to sendmail suddenly stops. In this case after 276 bytes. So Postfix is unable to send the mail as the header is incomplete and missing the To: field.

One possibility may be that the PHP script gets killed due to low memory. Or other cleanup tasks that eliminate the process that pipes the mail. While sendmail/Postfix is still running as expected.