| 1 |
#!/bin/sh |
| 2 |
|
| 3 |
usage() { |
| 4 |
echo " usage: $0 <example.com> [qpsmtpd username]" |
| 5 |
echo " " |
| 6 |
exit |
| 7 |
} |
| 8 |
|
| 9 |
if [ -z $1 ]; |
| 10 |
then |
| 11 |
usage |
| 12 |
fi |
| 13 |
|
| 14 |
DOMAIN=$1 |
| 15 |
SMTPD=$2 |
| 16 |
if [ -z $SMTPD ]; |
| 17 |
then |
| 18 |
SMTPD="smtpd" |
| 19 |
fi |
| 20 |
|
| 21 |
# create a directory for each DKIM signing domain |
| 22 |
mkdir -p $DOMAIN |
| 23 |
cd $DOMAIN |
| 24 |
|
| 25 |
# create a selector in the format mmmYYYY (apr2013) |
| 26 |
date '+%h%Y' | tr "[:upper:]" "[:lower:]" > selector |
| 27 |
|
| 28 |
# generate a private and public keys |
| 29 |
openssl genrsa -out private 2048 |
| 30 |
chmod 400 private |
| 31 |
openssl rsa -in private -out public -pubout |
| 32 |
|
| 33 |
# make it really easy to publish the public key in DNS |
| 34 |
cat > dns <<EO_DKIM_DNS |
| 35 |
|
| 36 |
`cat selector | tr -d "\n"`._domainkey TXT "v=DKIM1;p=`grep -v -e '^-' public | tr -d "\n"`" |
| 37 |
|
| 38 |
Tell the world that the ONLY mail servers that send mail from this domain are DKIM signed and/or bear our MX and A records. |
| 39 |
|
| 40 |
With SPF: |
| 41 |
|
| 42 |
SPF "v=spf1 mx a -all" |
| 43 |
TXT "v=spf1 mx a -all" |
| 44 |
|
| 45 |
With DMARC: |
| 46 |
|
| 47 |
_dmarc TXT "v=DMARC1; p=reject; adkim=s; aspf=r; rua=mailto:dmarc-feedback@$DOMAIN; ruf=mailto:dmarc-feedback@'$DOMAIN; pct=100" |
| 48 |
|
| 49 |
With DomainKeys (deprecated) |
| 50 |
|
| 51 |
_domainkey TXT "o=-; t=y; r=postmaster@$DOMAIN" |
| 52 |
|
| 53 |
For more information about DKIM and SPF policy, the documentation within each plugin contains a longer discussion and links to more detailed information: |
| 54 |
|
| 55 |
perldoc plugins/dkim |
| 56 |
perldoc plugins/sender_permitted_from |
| 57 |
|
| 58 |
|
| 59 |
EO_DKIM_DNS |
| 60 |
|
| 61 |
cd .. |
| 62 |
chown -R $SMTPD:$SMTPD $DOMAIN |