php mail() 554 error

  • Filter
  • Time
  • Show
Clear All
new posts

    php mail() 554 error

    I'm trying to set up a fairly simple mailing form to allow admins to send emails to different selection lists within databases. When tested to addresses on the same server (different domain) they work fine - when sent outside they fail with:

    This message was created automatically by mail delivery software.

    A message that you sent could not be delivered to one or more of its recipients. This is a permanent error. The following address(es) failed:

    [email protected]
    SMTP error from remote mail server after end of data:
    host []: 554 Message is not RFC compliant

    ------ This is a copy of the message, including all the headers. ------

    Return-path: <[email protected]>
    Received: from ([]:46254 helo=localhost)
    by with esmtpsa (TLSv1:AES256-SHA:256)
    (Exim 4.69)
    (envelope-from <[email protected]>)
    id 1Q9alV-0000fu-HO
    for [email protected]; Tue, 12 Apr 2011 11:24:09 +0100
    From: [email protected]
    To: [email protected]
    Subject: Test
    Test to outside

    The relevant bit of the php script is:

    while ($row = mysqli_fetch_assoc($emailqueryresult))

    echo "mailing to:". $row['Email2']."<br />";

    $to = trim($row['Email2']);

    $body = "Dear {$row['Title']} {$row['Last_Name']} \n\n $message";

    $headers = array ('From' => $from,
    'To' => $to,
    'Subject' => $subject);
    $smtp = Mail::factory('smtp',
    array ('host' => $host,
    'auth' => true,
    'username' => $username,
    'password' => $password));

    $mail = $smtp->send($to, $headers, $body);

    if (PEAR::isError($mail)) {
    echo("<p>" . $mail->getMessage() . "</p>");
    } else {
    echo("<p>Message successfully sent!</p>");

    Any ideas gratefully received!!


    Last edited by peabrain; 12-04-2011, 10:54. Reason: sorry - left in a couple of hash test lines

    I don't see Message-ID or Date headers in the messages that are generated. This might be the cause for rejection. SMTP needs the lines to be CRLF delimited. This might be one of the causes.

    You can also try and make changes to the setting for the New version of mail server.
    Go to Setup >> Miscellaneous Options >> Servers tab >> SMTP server checks >> message >> parameters for RFC compliance. Disable the message check as the problem seems to be with the message itself. The MailDaemon should now allow the messages to get passed. If this works fine, you can check the reason that is making it non-RFC compliant.

    Do let us know if that works for you....


      Thanks for your fast and helpful response.

      I'm disinclined to mess with the mailserver settings - I imagine receiving servers will be unhappy too!

      I haven't set message id or date headers... I assumed perl/phpmail dealt with those? Or should I set them myself?

      When I use the same form to send to another domain address within the server, it all works fine and I get the following headers:

      Return-path: <[email protected]>
      Envelope-to: [email protected]
      Delivery-date: Mon, 11 Apr 2011 01:24:31 +0100
      Received: from ([]:52108 helo=localhost)
      by with esmtpsa (TLSv1:AES256-SHA:256)
      (Exim 4.69)
      (envelope-from <[email protected]>)
      id 1Q94vf-0008Am-Nf
      for [email protected]; Mon, 11 Apr 2011 01:24:31 +0100
      From: [email protected]
      To: [email protected]
      Subject: abcdef

      This seems to have generated the date, though not a message ID - though I could force them? I'm not sure how to set up a message id... do I just generate a sha for each message?

      I have not used CRLF between headers - so I'll try and give that a go.

      Once I've got something that works, I'll post the core code for reference by others.

      Many thanks again



        Problem solved.

        I think the issue with the headers is the inclusion of the helo=localhost. I tried to tweak this by using Net_SMTP, but it kept tripping over at line 700 odd - and life's too short!

        I'm now using sendmail for smtp authentication - based on the script at All works fine and no more problems with emails failing or ending up in the junk box.
        Last edited by peabrain; 13-04-2011, 15:34. Reason: trying to get link right!