summaryrefslogtreecommitdiff
path: root/emailwiz.sh
diff options
context:
space:
mode:
authortfasano1 <54379134+tfasano1@users.noreply.github.com>2024-01-17 01:56:33 -0500
committerGitHub <noreply@github.com>2024-01-17 01:56:33 -0500
commite4ae00cd69e2651c03139487723173a0b0c9abde (patch)
tree9e6c9cc52a6248a9b333cd43870fd02b6026f85c /emailwiz.sh
parent9861a6af1ee3ae33a6722a7956761b84a2ab3d04 (diff)
Add spf arg to lower gmail false positive spam
Diffstat (limited to 'emailwiz.sh')
-rw-r--r--emailwiz.sh6
1 files changed, 5 insertions, 1 deletions
diff --git a/emailwiz.sh b/emailwiz.sh
index ce8e1f5..98151fd 100644
--- a/emailwiz.sh
+++ b/emailwiz.sh
@@ -347,10 +347,14 @@ for x in opendkim dovecot postfix fail2ban; do
systemctl enable "$x"
done
+# In some cases, big name email services favor an spf record with certain mechanisms included.
+# See http://www.open-spf.org/SPF_Record_Syntax
+mailip=ip4:$(ping -c 1 $domain | grep -m1 -Eo '([0-9]+\.){3}[0-9]+')
+
pval="$(tr -d '\n' <"/etc/postfix/dkim/$domain/$subdom.txt" | sed "s/k=rsa.* \"p=/k=rsa; p=/;s/\"\s*\"//;s/\"\s*).*//" | grep -o 'p=.*')"
dkimentry="$subdom._domainkey.$domain TXT v=DKIM1; k=rsa; $pval"
dmarcentry="_dmarc.$domain TXT v=DMARC1; p=reject; rua=mailto:dmarc@$domain; fo=1"
-spfentry="$domain TXT v=spf1 mx a:$maildomain -all"
+spfentry="$domain TXT v=spf1 mx a:$maildomain ip4:$mailip -all"
mxentry="$domain MX 10 $maildomain 300"
useradd -m -G mail dmarc