sandra_henrystocker
Unix Dweeb

Relaying Mail from Subdomains

Analysis
Sep 8, 20092 mins

Many releases ago (starting with sendmail 8.9), sendmail defaults changed so that email would no longer be

relayed unless the application was specifically built or configured to allow this behavior. Too many spammers were taking advantage of the friendly posture of our mail servers to help them with their nasty business. If, on the other hand, you are sending mail to or from the local domain, no problem.

Relaying for sendmail is defined as mail coming from outside the domain being sent to outside the domain. For example, trying to send mail from a.com to c.com would involve a relay if asked of b.com and won’t be supported by b.com if relaying is denied.

The behavior on modern sendmail servers to refuse to relay mail can bite you, however, if what you want is to be able to send mail from a subdomain to systems on your parent domain. In this case, allowing mail to be fowarded can be altered with your sendmail settings.

If the relay_entire_domains feature is supported (which it generally is), all you have to do is add your subdomains to a file named /etc/mail/relay-domains and then restart sendmail. If a sendmail service on subatomic.particles.org needs to relay mail to or from hosts on the particles.org, add the parent domain to its relay-domains file.

# domainname
subatomic.particles.org
# cat /etc/mail/relay-domains
particles.org
# /etc/rc2.d/S88sendmail restart

If a finer-grained relay mechanism is needed, you can use the relay_hosts_only feature and allow relaying only to particular systems

# domainname
subatomic.particles.org
# cat /etc/mail/relay-domains
boson.particles.org
fermion.particles.org
# /etc/rc2.d/S88sendmail restart

You can also relay domains using the access_db feature, though a little more work is involved. You have to set up your access database, add records to it and run the makemap command to build the file sendmail will read. Then you still have to restart sendmail or send it an HUP signal so tha it will take note of the changes.

sandra_henrystocker

Sandra Henry-Stocker was a programmer, Linux systems administrator, security engineer and Linux journalist for most of her 30-year career. She describes herself as "USL" (Unix as a second language) but remembers enough English to write books and buy groceries. She lives in the mountains in Virginia where, when not working with or writing about Unix, she's chasing the bears away from her bird feeders. Tune into her 2-Minute Linux video tutorials and take command of your command line.

More from this author