How to set up SPF, DKIM, and DMARC for your sending domain

(mailfully.com)

54 points | by spy888 7 hours ago ago

24 comments

  • buredoranna 3 hours ago ago

    This looks like a pretty good resource.

    I'd like to add the following, which I continually reference and has led to repeatable success:

    https://www.linuxbabe.com/mail-server/setting-up-dkim-and-sp...

    And as far as confirming it works, I continually rely on sending to a gmail address.

    Under the three dots is "view original" which gives you

    SPF, DKIM, and DMARC results.

    (edit:formatting)

  • jcul 2 hours ago ago

    This is a cool site to visualise your SPF, DKIM, DMARC setup interactively.

    https://www.learndmarc.com/

    • dbbr an hour ago ago

      +1. I used this to set up DMARC and ended up signing up for their service. Only like ~$12/year and works.

  • gerdesj 39 minutes ago ago

    This was not written by an email admin. Start with the real basics:

    Your MTA should announce itself and DNS should agree. So your MTA says: HELO smtp.example.co.uk

    smtp.example.co.uk will resolve to an A record (say a.b.c.d) and a reverse lookup will also work:

    d.c.b.a.in-addr.arpa PTR smtp.example.co.uk.

    Remember this is all about reputation, so if you also DNSSEC sign example.co.uk, then you will look like you care about your domain reputation.

    Then do SPF, DKIM and DMARC. Note how the example for SPF stops at ~all and not -all. The rest is also superficial.

    Anyway, I run email systems that do the job properly and it is not trivial and certainly not formulaic. There is no shortcut to getting an IP address/range trusted.

    The advice on that page is ... good as far as it goes but woefully inadequate for running an email system. It's a good start.

    • adiabatichottub 21 minutes ago ago

      I think a better resource is http://www.open-spf.org/

    • albertgoeswoof 36 minutes ago ago

      They don’t do ips they just use SES, same as resend and a bunch of other email startups lately

      • gerdesj 34 minutes ago ago

        Sorry, what is SES?

        • taylortrusty 11 minutes ago ago

          Wait, you claim to run email systems and don't know what SES is?

        • dddw 24 minutes ago ago

          Simple Email Service, by AWS. Mainly tramsactional email, but noy exclusively

  • duhhhhh1212 an hour ago ago
    • dolebirchwood an hour ago ago

      Is the information actually wrong, misleading, or otherwise deficient?

      • duhhhhh1212 an hour ago ago

        Idk but I’m not wasting my time checking all that. Feel free to give us a detailed line by line analysis of what’s misleading/deficient.

        The reason for my comment is that we, the readers, are most likely gonna spend more time reading this post than the author(s) did writing it.

        • glitchcrab 36 minutes ago ago

          Thanks for the heads up, looks like this is a case of AI;DR (maybe I should get some bumper stickers printed).

          • gerdesj 32 minutes ago ago

            It clearly is AI generated but the ideas as presented are mostly sound.

            However, it is woefully incomplete.

  • jonathanlydall an hour ago ago

    We generally run on Microsoft 365 and use SendGrid for transactional emails such as password resets.

    Main domain has SPF set up correctly as per MS docs.

    We have the CNAME set up for a like em1234 sub-domain as per SendGrid’s docs which their docs say should cover SPF even if the emails we send have a from address of our main domain (eg noreply@example.com), this is apparently because receiving servers are supposed to do SPF checks against the replyTo address which sendgrid does populate with an address on the subdomain.

    This has worked fine for years, Gmail for example is happy and looking at mails from us says everything passes.

    However, we recently onboarded a large corporate whose server was blocking the SendGrid emails because it was checking the SPF against the from header rather than the replyTo.

    Only way to let the email through was to either add SendGrid SPF records to our main domain, or change the from address of the SendGrid emails, neither of which was 100% ideal.

    Not going to try tell the client they’ve configured their server wrong, but have they?

    • adiabatichottub 28 minutes ago ago

      SPF doesn't check the reply-to address, only that the host sending the mail is allowed to send mail for the domain in the MAIL FROM: header.

      See: http://www.open-spf.org/FAQ/What_it_does/

      Edit: for those unfamiliar with the intricacies of SMTP, the first three lines sent are HELO, MAIL FROM:, and RCPT TO:. The From: address that you see in your mail client is actually another header that gets sent once the server provisionally accepts the message based on the first three headers. It's the difference between the return address on the envelope of a paper letter, and an address printed on the letterhead of the actual letter.

    • mcmcmc an hour ago ago

      No, they haven’t. With your current config sounds like you are failing SPF alignment. Is your SPF record in strict mode? Do you have DMARC set up and are you DKIM signing the SendGrid emails from your domain?

  • adiabatichottub 3 hours ago ago

    I recently tried bouncing mail during the header phase when DMARC didn't align, but it rejected more legit emails than SPAM. Most of the junk we've been getting passes DMARC and has an unsubscribe link.

    • edelbitter an hour ago ago

      > Most of the junk we've been getting passes DMARC and has an unsubscribe link.

      You say that like its a problem.. its a formidable solution!

      Has worked for me for many years now: Just fail2ban-style block (groups of) relays that attempt to send an unsubscribe-link destined for a mailbox that never ever subscribes to anything. Those malicious-compliance folks add these unsubscribe links everywhere because they determined that its a cheap method for reducing blocks. That makes them reliably stand out whenever they hit strictly human-to-human mailboxes that simply never have any reason to "unsubscribe". Its like a honeypot, and all it took was a strict policy about what a tiny fraction of mailboxes can and cannot be used for.

      • adiabatichottub 35 minutes ago ago

        I'll have to ponder the method you describe. I know I could implement that on my own mailboxes and some automated endpoints, but not sure how that would work for other users on our domain.

    • thayne an hour ago ago

      DMARC doesn't really do much to prevent general spam. It prevents spoofing the from address, which provides some protection against phishing, but if the email is from the domain it claims to be, it can pass DMARC whether or not it is spam.

      • adiabatichottub an hour ago ago

        Indeed. Ultimately we're still relying on blacklists, Bayesian filters, and hueristics to detect actual SPAM.

  • albertgoeswoof 37 minutes ago ago

    This is an aws ses wrapper so is basically irrelevant in the email world

  • comrade1234 3 hours ago ago

    You also need to set up reverse dns to avoid ending up in spam folders at the big ones.