Postfix / sendmail config for DKIM, SPF and DMARC Tutorial Guide E-mail Delivery for Hotmail.com Gmail.com and More HowTo

This will be the goto to help solve e-mail delivery issues and talk about many practical issues that happen between developers, admins and scripts that send e-mail and do things that may not be acceptable or cause deliverability problems.

Sendmail Stuff

Edit /etc/mail/sendmail.mc

The problem is that if you send directly out from the server using the mail function, the Return-path of the e-mails will be username@thehostnameoftheserver.com.  Let's say the From Address is "hellothere@cooldomain.com", this is a problem becasue presumably you've signed the e-mail for "cooldomain.com" but some e-mail providers will also check the Return-path domain of "thehostnameoftheserver.com" and find it does not match and there is no signature for the hostname and this will cause e-mails to be rejected or sent to spam.

So if your server's hostname is abc123.com, then the return path is the user@abc123.com, and this obviously breaks more strict DKIM checks because e-mail servers like gmail.com will also expect a DKIM signature for the hostname of the server.

To make things worse, a lot of times the people/devs that generate these e-mails may not have access to the server or may not be allowed to change the hostname.

Fix it Using Sendmail's MASQUERADE

Below we can fix this by using MASUERADE_AS with realtechtalk.com, this will be the domain set in the Return-path and the MASQUERADE_DOMAIN is abc123.com, you can add more lines with extra domains you want to rewrite.

dnl MASQUERADE_AS(`realtechtalk.com')dnl
dnl FEATURE(masquerade_entire_domain)dnl
dnl MASQUERADE_DOMAIN(abc123)dnl

 

To apply the changes update sendmail.cf like this:

We have to generate the new config file

m4 sendmail.mc

Restart the sendmail service.

systemctl restart sendmail

OpenDKIM Settings

Be sure to set this option for /etc/opendkim.conf as this will sign for multiple domains/hosts in the e-mail:

MultipleSignatures Yes

Eg. if your return-path is abc123.com and your from address is hello.com, both need to be signed or they will fail DMARC and possibly be blocked or sent to spam.  This also assumes that you should correctly have the keys and configuration to sign all domains that may be a part of the e-mail (eg. our example should mean that you have keys for abc123.com and hello.com on your server that sends out). 

 


Tags:

postfix, sendmail, config, dkim, spf, dmarc, tutorial, hotmail, gmail, howtothis, goto, developers, admins, scripts, acceptable, deliverability, edit, etc, mc, server, mails, username, thehostnameoftheserver, quot, hellothere, cooldomain, becasue, presumably, ve, providers, domain, hostname, rejected, spam, abc, user, strict, servers, devs, generate, masquerade, masuerade_as, realtechtalk, masquerade_domain, domains, rewrite, dnl, masquerade_as, feature, masquerade_entire_domain, update, cf, restart, systemctl,

Latest Articles

  • FreePBX 17 How To Add a Trunk
  • Docker Container Onboot Policy - How to make sure a container is always running
  • FreePBX 17 How To Add Phones / Extensions and Register
  • Warning: The driver descriptor says the physical block size is 2048 bytes, but Linux says it is 512 bytes. solution
  • Cisco How To Use a Third Party SIP Phone (eg. Avaya, 3CX)
  • Cisco Unified Communication Manager (CUCM) - How To Add Phones
  • pptp / pptpd not working in DD-WRT iptables / router
  • systemd-journald high memory usage solution
  • How to Install FreePBX 17 in Linux Debian Ubuntu Mint Guide
  • How To Install Cisco's CUCM (Cisco Unified Communication Manager) 12 Guide
  • Linux Ubuntu Redhat How To Extract Images from PDF
  • Linux and Windows Dual Boot Issue NIC Won't work After Booting Windows
  • Cisco CME How To Enable ACD hunt groups
  • How to install gns3 on Linux Ubuntu Mint
  • How to convert audio for Asterisk .wav format
  • Using Cisco CME Router with Asterisk as a dial-peer
  • Cisco CME How To Configure SIP Trunk VOIP
  • Virtualbox host Only Network Error Failed to save host network interface parameter - Cannot change gateway IP of host only network
  • Cisco CME and C7200 Router Testing and Learning Environment on Ubuntu 20+ Setup Tutorial Guide
  • Abusive IP ranges blacklist