Last active
February 24, 2022 01:59
-
-
Save daubac402/3354b53f0a27ff452a8c0f51b983eb04 to your computer and use it in GitHub Desktop.
Setup DKIM on Postfix Mail server.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ MYDOMAIN=yourdomain.com | |
$ mkdir -p /etc/mail/dkim-keys/$MYDOMAIN | |
$ cd /etc/mail/dkim-keys/$MYDOMAIN | |
$ opendkim-genkey -t -s mail -d $MYDOMAIN | |
# if opendkim-genkey command is not found, install it# | |
# Eg: With Centos 7: | |
$ rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm | |
$ sudo yum install -y opendkim | |
# 2 news file will be generated: mail.private and mail.txt | |
# add this line to /etc/mail/dkim-key | |
$ vim /etc/mail/dkim-key | |
-> | |
*@you:you:/etc/mail/dkim-keys/yourdomain.com/mail.private | |
# for eg: | |
*@ec2-user:ec2-user:/etc/mail/dkim-keys/yourdomain.com/mail.private | |
# Edit DKIM configuration file /etc/opendkim.conf and update below values in configuration file. | |
$ vim /etc/opendkim.conf | |
-> | |
Domain yourdomain.com | |
KeyFile /etc/mail/dkim-key | |
Selector mail | |
Socket inet:8892@localhost | |
# Now edit POSTFIX configuration file /etc/postfix/main.cf and add following values at the end of file | |
$ vim /etc/postfix/main.cf | |
-> | |
milter_default_action = accept | |
milter_protocol = 2 | |
smtpd_milters = inet:localhost:8892 | |
non_smtpd_milters = inet:localhost:8892 | |
# Configure DNS Entry using info from mail.txt | |
... | |
# Set permission | |
$ sudo chown opendkim:opendkim /etc/mail/dkim-key | |
$ sudo chmod 400 /etc/mail/dkim-key | |
# Restart Service | |
$ sudo service opendkim restart | |
$ sudo service postfix restart | |
# Verify DKIM | |
$ mail -vs "Test DKIM" [email protected] < /dev/null |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment