Prochaine révision | Révision précédente |
tutoriaux:install-email-server-part-4 [2022/08/18 10:50] – ↷ Liens modifiés en raison d'un déplacement. frater | tutoriaux:install-email-server:install-email-server-part-4 [2023/01/06 16:51] (Version actuelle) – créée - modification externe 127.0.0.1 |
---|
====== Build Email Server From Scratch on Debian – Part 4 - SPF & DKIM Setup ====== | ====== Build Email Server From Scratch on Debian – Part 4 - SPF & DKIM Setup ====== |
| |
After completing [[tutoriaux:install-email-server-part-1|part 1]], [[tutoriaux:install-email-server-part-2|part 2]] and [[tutoriaux:install-email-server-part-3|part 3]], we have a working Postfix SMTP server and Dovecot IMAP server. We can send and receive emails using a desktop email client. In this tutorial, we are going to learn how to improve email delivery to the recipient’s inbox by setting up SPF and DKIM on Debian server. | After completing [[tutoriaux:install-email-server:install-email-server-part-1|part 1]], [[tutoriaux:install-email-server:install-email-server-part-2|part 2]] and [[tutoriaux:install-email-server:install-email-server-part-3|part 3]], we have a working Postfix SMTP server and Dovecot IMAP server. We can send and receive emails using a desktop email client. In this tutorial, we are going to learn how to improve email delivery to the recipient’s inbox by setting up SPF and DKIM on Debian server. |
| |
===== What are SPF and DKIM Records? ===== | ===== What are SPF and DKIM Records? ===== |
The ''txt'' option tells ''dig'' that we only want to query TXT records. | The ''txt'' option tells ''dig'' that we only want to query TXT records. |
| |
{{tutoriaux:debian-email:debian-spf-domain.png}} | {{ tutoriaux:debian-email:debian-spf-domain.png?1000 |}} |
| |
You can also use the [[https://dmarcian.com/spf-survey/|dmarcian SPF surveyor]] to test your SPF record syntax. | You can also use the [[https://dmarcian.com/spf-survey/|dmarcian SPF surveyor]] to test your SPF record syntax. |
In your DNS manager, create a TXT record, enter ''default._domainkey'' in the name field. Then go back to the terminal window, copy everything in the parentheses and paste it into the value field of the DNS record. You need to delete all double quotes and white spaces in the value field. If you don’t delete them, then the key test in the next step will probably fail. | In your DNS manager, create a TXT record, enter ''default._domainkey'' in the name field. Then go back to the terminal window, copy everything in the parentheses and paste it into the value field of the DNS record. You need to delete all double quotes and white spaces in the value field. If you don’t delete them, then the key test in the next step will probably fail. |
| |
[[dkim record]] | [[..:dkim_record]] |
===== Test DKIM Key ===== | ===== Test DKIM Key ===== |
| |
If everything is OK, you will see ''Key OK'' in the command output. | If everything is OK, you will see ''Key OK'' in the command output. |
| |
<code> | {{ tutoriaux:debian-email:debian-opendkim-testkey.png |}} |
opendkim-testkey: using default configfile /etc/opendkim.conf | |
opendkim-testkey: checking key 'default._domainkey.example.com' | |
opendkim-testkey: key secure | |
opendkim-testkey: key OK | |
</code> | |
| |
Note that your DKIM record may need some time to propagate to the Internet. Depending on the domain registrar you use, your DNS record might be propagated instantly, or it might take up to 24 hours to propagate. You can go to https://www.dmarcanalyzer.com/dkim/dkim-check/, enter ''default'' as the selector and enter your domain name to check DKIM record propagation. | Note that your DKIM record may need some time to propagate to the Internet. Depending on the domain registrar you use, your DNS record might be propagated instantly, or it might take up to 24 hours to propagate. You can go to https://www.dmarcanalyzer.com/dkim/dkim-check/, enter ''default'' as the selector and enter your domain name to check DKIM record propagation. |
</code> | </code> |
| |
[[debian opendkim unix socket]] | [[..:debian_opendkim_unix_socket]] |
| |
Save and close the file. | Save and close the file. |
You can now send a test email from your mail server to your Gmail account to see if SPF and DKIM checks are passed. On the right side of an opened email message in Gmail, if you click the ''show original'' button from the drop-down menu, you can see the authentication results. | You can now send a test email from your mail server to your Gmail account to see if SPF and DKIM checks are passed. On the right side of an opened email message in Gmail, if you click the ''show original'' button from the drop-down menu, you can see the authentication results. |
| |
[[Gmail SPF and DKIM check scalahosting]] | {{ tutoriaux:debian-email:debian-opendkim-gmail-report.png |}} |
| |
If your message is not signed and DKIM check failed, you can check postfix log (''/var/log/mail.log'') to see what’s wrong with your configuration. | If your message is not signed and DKIM check failed, you can check postfix log (''/var/log/mail.log'') to see what’s wrong with your configuration. |
dkim-atps=neutral | dkim-atps=neutral |
</code> | </code> |
===== Step 10: Testing Email Score and Placement ===== | ===== Testing Email Score and Placement ===== |
| |
You can also go to https://www.mail-tester.com. You will see a unique email address. Send an email from your domain to this address and then check your score. As you can see, I got a perfect score. | |
| |
[[imporve email server reputation]] | You can also go to https://www.mail-tester.com. You will see a unique email address. Send an email from your domain to this address and then check your score (when you've complete the next [[tutoriaux:install-email-server:install-email-server-part-6|part]], you should have an **perfect** score). |
| |
Mail-tester.com can only show you a sender score. There’s another service called [[https://www.linuxbabe.com/glockapps|GlockApps]] that allow you to check if your email is placed in the recipient’s inbox or spam folder, or rejected outright. It supports many popular email providers like Gmail, Outlook, Hotmail, YahooMail, iCloud mail, etc | {{ tutoriaux:debian-email:debian-mail-tester-result.png |}} |
| |
[[glockapps email placement test scalahosting]] | |
| |
===== Microsoft Mailboxes ===== | ===== Microsoft Mailboxes ===== |