Dkim-add-domainkey
Create a DKIM key for a domain
Create a new folder and cd into it:
mkdir -p /etc/opendkim/keys/mydomain.com cd /etc/opendkim/keys/mydomain.com
Generate key:
opendkim-genkey -r -d mydomain.com
Delegate access to the opendkim user and group to access the key:
chown opendkim:opendkim default.private
Reference the key via OpenDKIM KeyTable:
vi /etc/opendkim/KeyTable
Add line to the file to define your selector. In this example, we will call the selector default, but if your domain requires multiple DKIM keys, ensure you make this unique. You can modify the file by pressing i to enter insert mode in vi:
default._domainkey.mydomain.com mydomain.com:default:/etc/opendkim/keys/mydomain.com/default.private
Open the SigningTable file via vi
vi /etc/opendkim/SigningTable
Add the following line to the file by pressing i to enter insert mode (changing default if specified a different selector earlier on):
mydomain.com default._domainkey.mydomain.com
/etc/init.d/opendkim restart
Update DNS:
cat /etc/opendkim/keys/mydomain.com/default.txt
Create a new TXT record, name default._domainkey or default._domainkey.subdomain with the value between the quotes (don't include the quotes), e.g.:
v=DKIM1; h=sha256; k=rsa; s=email; p=ABCDEFG.....