Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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: serverfault.com/questions/442180/… –  Jim Jan 12 '13 at 22:55

1 Answer 1

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 *.mydomain.com

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

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

share|improve this answer

Your Answer

 
discard

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.