0

I have A VPS with multiple domains setup. Some of the domains have PHP sites that send email. It turns out that some email servers are rejecting those emails with error: "Sender address rejected: Domain not found".(This from logs in exim_mainlog on server).

The interesting thing is that the domain it is reporting to be using as the sender is not the one I set in php mail(), rather an internal server name.

So for example if my VPS master domain is mymasterdomain.com and I have multiple sites such as site1.com, site2.com, etc, then the php program that sends email will send the email with a from field set in the header to: [email protected] but the mail will be rejected with 'Sender address rejected: Domain not found in [email protected]'.

com.mymasterdomain.com is how the hosting company identifies my VPS server internally, and obviously it does not resolve to anything.

SPF records are set properly to include the IP address of the site. I did a test by using php to snd the same email to two addresses. One is rejecting it, but the other at a gmail account is accepting it, which lets me look at the headers.

I can see the problem- the headers have:


Received: from cpanelSite1Account by com.mymasterdomain.com with local (Exim 4.91) (envelope-from ) id 1fWXCF-0006ED-Vv; Fri, 22 Jun 2018 09:37:56 -0500

To: [email protected]

Subject: NEW INQUERY RECEIVED

X-PHP-Script: www.site1.com/inquire_process.php for XXX.XXX.XXX.XXX

X-PHP-Originating-Script: 522:inquire_process.php

From: [email protected]


The [From:] is correct, but the [Received: from] contains the VPS info which is giving me trouble.

How do I fix this? In php? in cpanel? in sendmail or exim settings? Any help would be appreciated - have been scratching my had a while now ...

1 Answer 1

1

This is what probably happens:

  1. The receiving MTA checks existence against envelope sender instead of From: header.
  2. The Sendmail called by PHP mail() function uses the [email protected] as envelope sender, while the [email protected] in headers parameter of mail(to,subject,message,headers,parameters); is only used for generating mail headers.
  3. Sendmail gets its own hostname from the first host found for itself in /etc/hosts.

You could fix this on any level (the solutions in corresponding order, not the best first):

  1. Make the domain/hostname used as envelope sender exist by adding an A record.
  2. Use additional parameter to give Sendmail the envelope sender:

    mail('[email protected]','subject','message', 'From: [email protected]', '-f [email protected]'); 

    From man sendmail:

    -f sender 

    Set the envelope sender address. This is the address where delivery problems are sent to.

  3. Add an existing hostname in your /etc/hosts line for 127.0.0.1 or the actual server IP. This must be an A record from an existing domain, pointing at your server.

I think the solution #2 is nearest to your goal while #1 and #3 may solve the problem behind.

1
  • Option 2 did the trick! Thx. Commented Jun 23, 2018 at 18:38

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.