0

I'm in a pickle yet again.

I have web and mail servers separated, due to mail being handeled by third-party app. On a website I have a contact form, that's using the mail() function. All of the services are sitting behind cloudflare's DNS. I'm fine sending and receiving mails via the app. Tho I'm helplessly greeted with an error back from the recipient MTA, saying: "550-Sender has no A, AAAA, or MX DNS records." I bet I configured something wrong or forgot to add a record to cloudflare. Care to point it out for me, pretty please?

Here are the error messages:

Last test mail

From MAILER-DAEMON Tue Aug 02 16:56:47 2016
Return-path: <>
Envelope-to: root@kati
Delivery-date: Tue, 02 Aug 2016 16:56:47 +0000
Received: from Debian-exim by Kati.<azure's provided FQDN> with local (Exim 4.84_2)
        id 1bUczn-000EE3-He
        for root@kati; Tue, 02 Aug 2016 16:56:47 +0000
X-Failed-Recipients: <recipient mail>
Auto-Submitted: auto-replied
From: Mail Delivery System <Mailer-Daemon@kati>
To: root@kati
Subject: Mail delivery failed: returning message to sender
Message-Id: <E1bUczn-000EE3-He@Kati.<azure's provided FQDN>>
Date: Tue, 02 Aug 2016 16:56:47 +0000

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:

  <recipient mail>
    SMTP error from remote mail server after RCPT TO:<recipient mail>:
    host mx1.privateemail.com [<recipient IP>]: 550-Sender has no A, AAAA, or MX DNS records.
    550 Kati.<azure's provided FQDN> kati

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

Return-path: <root@kati>
Received: from root by <azure's provided FQDN> with local (Exim 4.84_2)
        (envelope-from <root@kati>)
        id 1bUczl-000EDy-OE
        for <recipient mail>; Tue, 02 Aug 2016 16:56:45 +0000
To: <recipient mail>
Subject: Test
From:<sender mail>
Message-Id: <E1bUczl-000EDy-OE@Kati.<azure's provided FQDN>>
Date: Tue, 02 Aug 2016 16:56:45 +0000

Testing Exim

and the configurations:

Exim conf

dc_eximconfig_configtype='internet'
dc_other_hostnames='Kati; localhost'
dc_local_interfaces='127.0.0.1 ; ::1'
dc_readhost=''
dc_relay_domains=''
dc_minimaldns='false'
dc_relay_nets=''
dc_smarthost=''
CFILEMODE='644'
dc_use_split_config='false'
dc_hide_mailname=''
dc_mailname_in_oh='true'
dc_localdelivery='mail_spool'

1 Answer 1

0

First of all, due to missing details in your OP, I'm assuming that when you say: "...a contact form, that's using the mail() function..." you are referring to the PHP mail() function.

In such a case, you should note that the mail() function will simply launch the local "sendmail" binary application, as specified by the sendmail_path configuration directive (...and no, the "sendmail" binary is not strictly related to the "sendmail" mail-server). The execution of "sendmail" will be done in such a way to pass it several parameters ("to", "headers", etc). Please note, also, that I'm assuming you're running PHP under Linux, as in windows environments, mail() function works in a very different way

Based on above points, you easily guess that the delivery of your outbound e-mail, sent from PHP via the mail() function, is totally dependent on the correct configuration of the underlying mail server.

It's really common (unfortunately) that a freshly installed linux box is deployed with a not-properly-configured mail-server: an incorrect hostname, an incorrent domain/FQDN, a mismatch with DNS configuration as for hosts (A record) and reverse DNS (PTR record) are --based on my experience-- very common.

In your OP, I clearly recognize some of above "symptoms", from following rows:

Envelope-to: root@kati
[...]
To: root@kati
[...]
550-Sender has no A, AAAA, or MX DNS records

So, in other words, remote mail-servers (...that are receiving e-mails from your local mail-server.... that is receiving e-mail from PHP submitted via the sendmail binary) are complaining because your mail-server is not properly configured. And they are right. :-)

How to solve your problem?

You might guess that the only option is:

  1. clean/fix your mail-server configuration;

This is true... but is also very complex. A proper configuration of a full-featured mail-server is a really complex task and, if not done correctly, could quickly lead to further (and bigger) problems.

But... hey! We are missing the starting point! After all you want simply send an e-mail generated by a CONTACT FORM! So, the real question is: do we really need a fully configured mail-server to deliver such a very simple e-mail? This question lead us to the second option:

  1. refactor our PHP code so to NOT use the mail() function but, instead, acts like a "normal" SMTP-client towards an external (...and correctly configured by others) mail-server :-). Basically, you want to "bypass" the local sendmail binary, and send the e-mail via SMTP.

And this is what I suggest you: simply avoid using the mail() function and, instead, use some readily available SMTP-class. A good candidate is the SMTP implementation of the PEAR Mail interface. With such a module, it's really easy to point to an existing SMTP-server, even with authentication... and simply forget about local mail-server.

I leave to you the efforts to refactor your code as.... I really think it's so easy, to not require further explanations :-)

1
  • Cheers mate, decided to reconf the exim and added few aliases for it. Seems to be working now!
    – S.Suema
    Aug 3, 2016 at 2:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .