Thursday, January 11, 2018

How to install DKIM on Ubuntu server

Step 1: Install DKIM package
Use the following command in your terminal to install the DKIM package
sudo apt-get install opendkim opendkim-tools

Step 2: Edit configuration file

After installation of the package, there will be a config file created within the installed directory. Edit the config file  by adding the content given below at the end of the file.
KeyFile /etc/postfix/dkim.key
Selector mail
SOCKET inet:8891@localhost
Make sure to replace with your domain name.

Step 3: Install and configure Postfix

(Skip to next step if already installed and configured). Postfix is the standard Mail Transfer Agent for Ubuntu. Use the command below to install Postfix.
sudo apt-get install postfix
Follow the instructions on the screen and complete the installation process. Open the postfix config file using the following command and edit as follows.
vim /etc/postfix/
Add the following lines towards the end of the file, then save and exit by pressing ESC key followed by typing :wq! and then hit the Enterkey.
milter_default_action = accept
milter_protocol = 2
smtpd_milters = inet:localhost:8891
non_smtpd_milters = inet:localhost:8891

Step 4: DKIM key generation

Generate the DKIM key using the command
opendkim-genkey -t -s mail -d
This command will generate mail.private and mail.txt file. mail.private is private key that will be used to sign outgoing emails. Move it to /etc/opendkim.conf
cp mail.private /etc/postfix/dkim.key

Step 5: Setting DNS records

Open the mail.txt file using cat command
cat mail.txt
The result will look similar to this
mail._domainkey    IN    TXT    ( "v=DKIM1; k=rsa; t=y; "
      "p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDny/XOYgwb+zaDh/HNvrYVDIF5xRsVmKM4BKRyq4+3LVKvTtqtKG56wld1/xbBVRRtJKczYCjZPmDrepz7mXw+TSqYX5nURJdV+lxhHOK85c78ua4twI4XFfCrwr3q/kj4HuQLJ2ceN9VqRO5CoE5kPTunopNOB1Nv3TolP5wkKQIDAQAB" )  ; ----- DKIM key mail for
Use the data available to set up your DNS records for your corresponding domain name.

Step 6: Setting up and testing

Start your DKIM service using the command
sudo service opendkim start
Restart the postfix service once before testing your setup
sudo service postfix restart
Now its time to set your DKIM setup. There are a few ways to test the setup out of which use the following.

No comments:

Post a Comment

TicTic v2.2 - Android media app for creating and sharing short videos

Facebook Twitter Tiktik – Android app for creating and sharing short videos. The customizable social video application to build ...

Popular Posts