Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a single domain with a dozen subdomains for different sites. Each has a separate virtual host in apache.

I configured sendmail to masquerad as the top-level domain so that emails are always from the top-level domain instead of the subdomain.

Unfortunately, DKIM header d= and i= fields show the subdomain. Since the DNS Record is stored at the top-level domain, the DKIM Check fails.

How do I tell DKIM to use the top-level domain?

Please help.

p.s. I've tried every angle on this and I'm stumped. I can't figure out how Sendmail tells DKIM which subdomain to use. And I can't figure out how PHP tells Sendmail which subdomain is being used. I tried setting $_SERVER['SERVER_NAME'] to override it just before sending the mail, but it has no effect. I can't figure out a single work-around.

share|improve this question
Well evidentally, some pertinent information can be found here:… – Jim Jan 12 '13 at 22:55
up vote 1 down vote accepted

The problem stems from rewriting of headers and its discussed here: Sendmail rewriting headers after OpenDKIM signature

One of the suggested solutions is to set the correct headers in PHP so that sendmail is given the correct domain information and no rewriting is involved.

In my case, I realized that meant setting $_SERVER['SERVER_NAME'] is the right thing to do as an easy fix. I had mentioned it didn't work for me because I thought Sendmail was ignoring the value. But I tried it again and noticed Sendmail DOES recognize the value from $_SERVER['SERVER_NAME']. The problem I didn't realize before was that I had DKIM Filter configured incorrectly.

In dkim-filter.conf, I had the line: Domain *

When Sendmail was receiving "" in the header information and calling DKIM-Milter, DKIM was unable to find a match because "" evidentally doesn't match * I changed * to and everything started working.

So all I have to do on all my sites is set $_SERVER['SERVER_NAME'] = '' before calling mail() or wp_mail() (For WordPress). Everything works then.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.