Php mail is erratic: sometimes sends, sometimes doesn't

Dave Coventry asked:

I have a server set up to use postfix to send mail from the server.

When a user registers at my WordPress site, an email is sent to the administrators, both of whom have gmail addresses.

Sometimes it works and the emails are sent out to the administrators.

Sometimes the mail works fine

    Apr  2 16:39:32 server postfix/cleanup[7279]: 433319E245CB: message-id=<20160402163903.426959E245CC@mail.example.com>
    Apr  2 16:39:32 server postfix/smtpd[7289]: disconnect from localhost.localdomain[127.0.0.1]
    Apr  2 16:39:32 server postfix/qmgr[3806]: 433319E245CB: from=<www-data@example.co.uk>, size=1174, nrcpt=2 (queue active)
    Apr  2 16:39:32 server amavis[19869]: (19869-06) Passed CLEAN {RelayedOpenRelay}, <www-data@example.co.uk> -> <bwisxxxxxx@gmail.com>,<dgcoxxxxxx@gmail.com>, Message-ID: <20160402163903.426959E245CC@mail.example.com>, mail_id: kPBazIRbRnM0, Hits: 1.74, size: 760, queued_as: 433319E245CB, 28866 ms
    Apr  2 16:39:32 server postfix/smtp[7284]: 426959E245CC: to=<bwisxxxxxx@gmail.com>, relay=127.0.0.1[127.0.0.1]:10024, delay=29, delays=0.19/0.05/0.01/29, dsn=2.0.0, status=sent (250 2.0.0 from MTA(smtp:[127.0.0.1]:10025): 250 2.0.0 Ok: queued as 433319E245CB)
    Apr  2 16:39:32 server postfix/smtp[7284]: 426959E245CC: to=<dgcoxxxxxx@gmail.com>, relay=127.0.0.1[127.0.0.1]:10024, delay=29, delays=0.19/0.05/0.01/29, dsn=2.0.0, status=sent (250 2.0.0 from MTA(smtp:[127.0.0.1]:10025): 250 2.0.0 Ok: queued as 433319E245CB)
    Apr  2 16:39:32 server postfix/qmgr[3806]: 426959E245CC: removed
    Apr  2 16:39:32 server postfix/smtp[7292]: 433319E245CB: to=<bwisxxxxxx@gmail.com>, relay=gmail-smtp-in.l.google.com[2a00:1450:4013:c00::1b]:25, delay=0.56, delays=0.01/0.02/0.2/0.33, dsn=5.7.1, status=bounced (host gmail-smtp-in.l.google.com[2a00:1450:4013:c00::1b] said: 550-5.7.1 [2a00:d880:5:87f::4927] Our system has detected that this message does 550-5.7.1 not meet IPv6 sending guidelines regarding PTR records and 550-5.7.1 authentication. Please review 550-5.7.1  https://support.google.com/mail/?p=ipv6_authentication_error for more 550 5.7.1 information. q140si4479035wmg.33 - gsmtp (in reply to end of DATA command))
    Apr  2 16:39:32 server postfix/smtp[7292]: 433319E245CB: to=<dgcoxxxxxx@gmail.com>, relay=gmail-smtp-in.l.google.com[2a00:1450:4013:c00::1b]:25, delay=0.56, delays=0.01/0.02/0.2/0.33, dsn=5.7.1, status=bounced (host gmail-smtp-in.l.google.com[2a00:1450:4013:c00::1b] said: 550-5.7.1 [2a00:d880:5:87f::4927] Our system has detected that this message does 550-5.7.1 not meet IPv6 sending guidelines regarding PTR records and 550-5.7.1 authentication. Please review 550-5.7.1  https://support.google.com/mail/?p=ipv6_authentication_error for more 550 5.7.1 information. q140si4479035wmg.33 - gsmtp (in reply to end of DATA command))

But sometimes the emails are never sent:

    Apr  2 22:04:11 server postfix/pickup[16625]: 5082F9E245EF: uid=33 from=<www-data>
    Apr  2 22:04:11 server postfix/cleanup[18820]: 5082F9E245EF: message-id=<20160402220411.5082F9E245EF@mail.example.com>
    Apr  2 22:04:11 server postfix/qmgr[3806]: 5082F9E245EF: from=<www-data@example.co.uk>, size=761, nrcpt=2 (queue active)
    Apr  2 22:04:11 server postfix/smtp[18824]: connect to 127.0.0.1[127.0.0.1]:10024: Connection refused
    Apr  2 22:04:11 server postfix/smtp[18824]: 5082F9E245EF: to=<bwisxxxxxx@gmail.com>, relay=none, delay=0.07, delays=0.06/0.01/0/0, dsn=4.4.1, status=deferred (connect to 127.0.0.1[127.0.0.1]:10024: Connection refused)
    Apr  2 22:04:11 server postfix/smtp[18824]: 5082F9E245EF: to=<dgcoxxxxxxx@gmail.com>, relay=none, delay=0.07, delays=0.06/0.01/0/0, dsn=4.4.1, status=deferred (connect to 127.0.0.1[127.0.0.1]:10024: Connection refused)

I am at a loss to figure it out

My answer:


In your second set of log entries, it appears that amavis is not running, so the mail can’t be scanned for viruses, and thus it gets held in queue until such time as someone comes along and restarts amavis.


View the full question and answer on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.