Skip to main content
Home
The Baheyeldin Dynasty
The journey for wisdom starts with knowledge
  • Home
  • About
  • Site Map
  • Contact

Setting up SPF and DKIM on Postfix to overcome Yahoo/Verizon/Cox DMARC

  1. Home

By Khalid on 2014/10/24 - 15:35, last updated 2014/12/19 - 10:13

More and more large companies are implementing more restrictive email policies to fight increasing SPAM. These are mainly DMARC. Such companies include Yahoo, Cox, Verizon, and others.

As this happens, some of your legitimate email may be rejected because email servers are more restrictive.

In order to minimize the probability of your email being rejected, the following describes how to implement Sender Policy Framework (SPF) and DKIM on your already running Postfix mail server.

Prerequisites

Before you start, there are a few assumptions:

1. You have your own domain and run your own mail server.

2. Your server is running on Linux, preferrably Ubuntu or Debian.

3. You are using Postfix for your email server.

Configuring SPF with your correct DNS PTR record

Step 1: Find out your PTR Record

First you need to find out what the DNS PTR name for your server is. This is important because some mail servers will reject email from your server if the PTR returned matches what is in the SPF record. If they do not match, the mail will be rejected.

More info is available under: reverse DNS lookup.

The easiest way is to use the PTR record provided by your host. For example, if you are using Linode, the name will be something like liXXX-YYY.members.linode.com, where XXX and YYY are numbers.

Step 2: Generate an SPF record

The easiest way to generate an SPF record is using the SPF Wizard, then adding the PTR to it by adding:

include:liXXX-YYY.members.linode.com

Step 3: Configure SPF in a TXT record

In your DNS, create a new TXT record as follows, with no host name.

v=spf1 mx a include:_spf.google.com include:liXXX-YYY.members.linode.com ~all

Configuring OpenDKIM with Postfix

The configuration below assumes that you have the Postfix mail server already configured and working.

Step 1: Install the opendkim package

aptitude install opendkim

Step 2: Configure Postfix for opendkim

Edit /etc/postfix/main.cf, and change the following:

myhostname = liXXX-YYY.members.linode.com

milter_default_action = accept
milter_protocol = 2
smtpd_milters = inet:localhost:8891
non_smtpd_milters = inet:localhost:8891

Step 3: Edit the file /etc/mailname

Edit the /etc/mailname file, and put in it the canonical host name, which is the same as the PTR name above: liXXX-YYY.members.linode.com

Step 4: Generate a DKIM key

opendkim-genkey -t -s mail

Step 5: Copy it where opendkim will find it

cp mail.private /etc/opendkim/mail.private

Step 6: Add DKIM to your DNS

First, show the contents of the public DKIM key, so that you can add it in your domain's TXT field

cat mail.txt

Then in your DNS, add another TXT record with name "mail._domainkey" as follows:

v=DKIM1; k=rsa; t=y;
p=...
;

Replace the "..." above with your real public DKIM key.

Restart the services on your host

Finally, restart opendkim and Postfix, and then test your email, and review your logs.

service opendkim restart
service postfix restart

You should see less email being rejected now.

Contents: 
Linux
Tags: 
DKIM
opendkim
SPF
DMARC
  • Add comment

Current

Pandemic

  • COVID-19
  • Coronavirus

Search

Site map

Contents

  • Family
    • Khalid
    • Ancestry
    • Extended
  • Friends
  • Nokat نكت
  • Writings
    • Cooking
    • Culture
    • Science
    • History
    • Linguistics
    • Media
    • Literature
    • Politics
    • Humor
    • Terrorism
    • Business
    • Philosophy
    • Religion
    • Children
  • Technology
    • Linux
    • Arabization
    • Drupal
      • Association
    • Software
    • Internet
    • Technology in Society
    • Digital Archeology
    • NCR History
    • MidEast Internet
    • Programming
    • Saudi ISPs
    • Miscellaneous
  • Places
    • Canada
      • Weather
    • Egypt
      • Cuisine
      • Alexandria
      • E.G.C.
    • USA
    • Saudi Arabia
  • Interests
    • Astronomy
    • Fishing
    • Photography
    • Snorkeling
    • Nature
    • Photomicroscopy
  • Miscellany

In Depth

  • al-Hakim bi Amr Allah: Fatimid Caliph of Egypt الحاكم بأمر الله
  • Alexandria, Egypt
  • Arabic on the Internet
  • Articles on the history of Muslims and Arabs in the Iberian Peninsula تاريخ المسلمين و العرب في الأند
  • DIY GOTO Telescope Controller With Autoguiding and Periodic Error Correction
  • E.G.C. English Girls College in Alexandria, Egypt
  • Egyptian Cuisine, Food and Recipes مأكولات مصرية
  • George Saliba: Seeking the Origins of Modern Science?
  • Internet Scams and Fraud
  • Mistaken for an Arab or Muslim: Absurdities of being a victim in the War on Terror
  • Mistaken Identity: How some people confuse my site for others
  • One People's Terrorist Is Another People's Freedom Fighter
  • Overview of Google's Technologies
  • Photomicroscopy
  • Pseudoscience: Lots of it around ...
  • Resources for using Google Adsense with Drupal
  • Rockwood Conservation Area, Southern Ontario
  • Selected Symbolic Novels And Movies
  • Snorkeling the Red Sea near Jeddah
  • Updates and Thoughts on the Egyptian Revolution of 2011

Recent Content

Most recent articles on the site.

  • Origin Of COVID-19: Natural Spillover, Lab Leak Or Biological Weapon?
  • Kamal Salibi and the "Israel from Yemen" theory
  • How To Upgrade HomeAssistant Core In A Python Venv Using uv
  • Ancestry - Paternal Side
  • Review of Wait Water Saver For Whole House Humidifiers
more

Most Comments

Most commented on articles ...

  • Another scam via Craigslist: offering more than asking price
  • Warning to female tourists thinking of marrying Egyptians
  • Craigslist classified for used car: Cheque fraud scam
  • Winning the lottery scam email: World Cup South African lottery
  • Email Scam: BMW 5 Series car and lottery winning
more

About Khalid

Various little bits of information ...

  • Khalid Baheyeldin: brief biography
  • Presentations and Talks
  • Youtube Videos
  • GitHub Projects
  • Drupal.org Profile
  • Astrophotography @ Flickr

Sponsored Links

Your Link Ad Here

Tags

Android Mobile Ubuntu Sony OnStep OpenWRT Router Ericsson COVID-19 Rogers Coronavirus Arabic Kubuntu Home Assistant GSM Telescope tablet Spectrum Scam Python 419 Laptop Firefox DIY CPU Conspiracy Comet Balkanization backup App
More

© Copyright 1999-2025 The Baheyeldin Dynasty. All rights reserved.
You can use our content under the Terms of Use.
Please read our privacy policy before you post any information on this site.
All posted articles and comments are copyright by their owner, and reflect their own views and opinions, which may not necessarily be consistent with the views and opinions of the owners of The Baheyeldin Dynasty.

Web site developed by 2bits.com Inc.