Early access is open. Stagd is free during the beta. Sign up
← Blog

Our sign-in codes went to Junk, and every check passed

SPF, DKIM and DMARC all passed, and Microsoft 365 still put our mail in Junk. What the headers said, what didn't help, and what did.

· Cover image

Stagd signs people in with a code by email. People who review previews, such as designers, product managers and clients, often have no GitHub account, so the code is how they get in. It has one job: arrive within a minute, in the inbox.

At a Gmail address it did. At a Microsoft 365 address it went to Junk, or didn’t show up at all. This is how we found out why, and why the usual checklist wasn’t the answer.

The checklist was green

When mail goes to spam, the first suspects are always the same three records, so we checked them first:

  • SPF: passed, through the bounce domain our sending service uses.
  • DKIM: passed, signed for our own domain.
  • DMARC: passed, with a p=reject policy, the strictest there is.

Microsoft agreed. The headers of a junked code said so in its own words:

spf=pass  dkim=pass header.d=stagd-staging.dev  dmarc=pass
compauth=pass reason=100

compauth=pass is Microsoft’s own verdict on whether the sender is who they say they are. So authentication wasn’t the problem. Every guide that starts with “check your SPF record” had nothing more to tell us.

What the headers actually said

The line that mattered was further down:

SCL:5; SFV:SPM; CAT:SPM; BCL:0
  • SCL 5 is the spam confidence level. Five and above goes to Junk.
  • SFV:SPM means the spam filter marked it as spam.
  • BCL:0 is the bulk complaint level: zero, so not a newsletter or marketing mail.

Microsoft believed the mail came from us, and still thought it looked like spam. That’s a verdict about reputation, not identity: who has sent from this domain and this IP before, and how people reacted to it.

And we had no reputation. The domain was new, and its mail went out through our provider’s shared IP, 104.30.16.132, which carries the history of everyone else sending through it. Gmail weighs that differently and delivered it to the inbox. Microsoft didn’t.

What we tried

A From domain that can receive mail. Staging’s sending domain had no MX record and no root SPF record: it could send mail but not receive any. That’s a known mark against a sender in Microsoft 365. We turned on mail routing for it, which gave it MX records and a root SPF. Staging’s codes went from not arriving at all to arriving in Junk. Progress, of a kind.

No hidden preheader. Our mail had a preheader: hidden text at the top that inboxes show as a preview line. Hidden text is a classic spam signal, so we removed it. The next code got the same verdict, SCL:5. It wasn’t the cause, but we’ve left it out since: the heading and first lines make a fine preview.

A reply-to someone reads. Our mail came from no-reply@, and a sender nobody can answer counts against it. Replies now go to hello@stagd.dev, a mailbox we read. It’s better for the people getting the mail too: someone who answers an invite reaches a person.

A message id for every mail. The server now logs our provider’s message id for each mail it sends. The next code that goes missing can be found in Microsoft 365’s message trace, instead of guessed at.

Where it stands

Our sign-in codes now reach the inbox at Microsoft 365, still sent through the same provider. We can’t point to one thing that did it. Most likely it’s the fixes above, and time: reputation is built by sending mail people want and open.

If they slip back into Junk, two things help:

  • Marking it as not junk. When a code lands in Junk, “Not junk” in Outlook, and a submission to Microsoft as a false positive, both count in the sender’s favour.
  • A sending service with standing at Microsoft. Services that send only transactional mail, such as Postmark, keep their shared IPs clean, and their mail usually reaches the inbox from the first day. Every mail Stagd sends goes through one function, so moving is a small change, and we’ll make it if codes start landing in Junk again.

Sign-in doesn’t have to rely on mail at all, either. Reviewers can sign in with Google, with Microsoft to follow, so most of them use an account they already have, and the code is the fallback.

What we’d tell you

  • Passing SPF, DKIM and DMARC means Microsoft knows it’s you. It doesn’t mean Microsoft trusts you. Read the X-Forefront-Antispam-Report header: SCL and SFV say what the filter decided.
  • A new domain on a shared IP starts with no standing. Gmail and Microsoft 365 treat that differently, so test with both before your users do.
  • Make the From domain able to receive mail, and give people a reply-to they can use.
  • Log a message id for every mail, so a missing one can be traced rather than guessed at.

Stagd gives every pull request its own preview, with its own database and a link in the review. Its previews catch your app’s mail too, in an inbox reviewers can read, so nothing a preview sends reaches a real person. Try it, or tell us about your own mail troubles at hello@stagd.dev.