Add SPF record for your email relay server to avoid being counted as a spam
Step 1. Add SPF record to your DNS server
Create TXT record type and add the following text without quotes “”
@ TXT "v=spf1 a mx include:myrelay.com ~all" |
Step 2. Check if SPF record is added correctly
username@laptop:/home/username# dig myhostname.com TXT <<>> DiG 9.10.3-P4-Ubuntu <<>> myhostname.com TXT ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 62028 ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1 ;; OPT PSEUDOSECTION: ; EDNS: version: 0, flags:; udp: 4000 ;; QUESTION SECTION: ;myhostname.com. IN TXT ;; ANSWER SECTION: myhostname.com. 86400 IN TXT "v=spf1 a mx include:myrelay.com ~all" ;; Query time: 7 msec ;; SERVER: 127.0.1.1#53(127.0.1.1) ;; WHEN: Wed Nov 22 13:36:40 GMT 2017 ;; MSG SIZE rcvd: 104 |
Step 3. Test it by sending email to your gmail account, then go the receiver’s mailbox and check email source header
Received-SPF: pass (google.com: domain of www-data@myhostname.com designates 24.33.20.159 as permitted sender) client-ip=24.33.20.159; Authentication-Results: mx.google.com; spf=pass (google.com: domain of www-data@myhostname.com designates 24.33.20.159 as permitted sender) smtp.mailfrom=www-data@myhostname.com |