Why do my order confirmations end up in spam? SPF, DKIM, DMARC and the sender rules

TL;DR

Difficulty: Intermediate

When a shop's own order emails land in spam, every system still reports success. The leak shows up as "where is my order" contacts.

  • In the example, 6% of order emails to Gmail and Outlook land in spam: 120 extra contacts a month, £540 a month, £6,480 a year, before failed password resets and lost repeat orders.
  • The usual causes: order mail not signed with the shop's own domain, no enforced DMARC, an SPF record over its 10 lookup limit, and a newsletter from the same domain collecting complaints.
  • Since 2024 Google and Yahoo, and since May 2025 Microsoft, require SPF, DKIM and DMARC from bulk senders, and a newsletter to a few thousand people makes a shop one.
  • Fix in order: list every sender, sign order mail with your domain, DMARC with reports, fix every sender, separate marketing, enforce. Then measure contacts per 100 orders by mailbox provider every quarter.

An order confirmation that lands in spam costs nothing you can see on a dashboard. It costs a "where is my order" message, a password reset that never arrives, and sometimes the next order. This chapter shows how mailbox providers decide, what SPF, DKIM and DMARC do, which rules Google, Yahoo and Microsoft enforce, and how to find and fix the leak in a Rails and Solidus shop.

The email the customer never saw

A customer pays for a lamp at 9.40pm. The payment goes through, the order lands in the shop, and the confirmation email leaves the server a few seconds later. Then nothing. The customer checks their inbox before bed and finds no message. The next morning they write to the shop: "Did my order go through?"

Nobody did anything wrong. The order is fine, the lamp is in stock, and the email was sent. It simply landed in the spam folder, where the customer never looks. Multiply that by a few hundred customers a month and you have one of the quietest leaks an online shop can have. It does not show up in the conversion rate, it does not show up in the revenue report, and the payment provider reports every order as a success. It shows up as a steady trickle of "where is my order" messages, as password resets that never arrive, and as customers who quietly decide the shop felt a bit unreliable.

This chapter answers one question: why do order confirmations and password resets end up in spam, and what does that cost? It explains how Gmail, Outlook and Yahoo decide where a message goes, what Sender Policy Framework (SPF), DomainKeys Identified Mail (DKIM) and Domain based Message Authentication, Reporting and Conformance (DMARC) actually do, which rules the big mailbox providers now enforce, and how to find and fix the leak in a shop built on Ruby on Rails and Solidus. It is the third chapter of a series; the first chapter maps every quiet leak and puts this one in context.

Example: Priya's Monday inbox

The example for the whole series is Wrenfield Home, an online homeware shop in Leeds (wrenfieldhome.example), run by Priya, with Callum as her developer and data engineer. It sells about 1,400 products, takes 1,980 orders a month at an average order value of £72, and keeps £19.86 of contribution per order. All figures in this chapter are the example's, invented for teaching, unless a footnote says otherwise.

Every Monday Priya opens the customer service tool and works through the weekend's messages. Over the last year she has noticed that a large share of them ask the same thing: "Has my order been received?", "I never got a confirmation", "Where is my tracking number?". She tags them "where is my order", answers each one by hand, and moves on. In a typical month there are about 300 of them. She assumes that is just what customers are like.

It is not. As the rest of this chapter shows, about 120 of those 300 contacts a month exist only because the shop's own emails landed in spam.

What a quiet email leak costs

Start with the money, because it decides how much effort the fix deserves. A missing order email costs in three ways.

  • Extra contacts. A customer who gets no confirmation or no tracking email asks for it. Each contact takes someone's time.
  • Failed password resets. A customer who cannot reset a password often gives up, or checks out as a guest and loses their order history.
  • Lost repeat orders. A shop that feels unreliable after the first order is less likely to get the second. The chapter on repeat purchase and churn shows how much of a shop's value sits in that second order.

Only the first is easy to count, so this chapter counts only the first. The other two come on top.

The monthly cost of the extra contacts is a plain multiplication. If ratios like these are new, Foundations: ratios and rates explains them from the start.

C=N×cC = N \times c

CC is the monthly cost of the leak, NN is the number of extra contacts a month that the email problem causes, and cc is what it costs the shop to handle one contact (the minutes of the person answering, at what that person costs, plus the tool).

Example: the cost of 120 extra contacts

At Wrenfield Home a contact takes about six minutes to read, look up and answer, and with wages, on costs and the customer service tool the shop puts the cost at £4.50 a contact. The email problem causes 120 extra contacts a month.

C=120×4.50=540C = 120 \times 4.50 = 540

That is C=540C = 540, so £540 a month, and over a year:

540×12=6480540 \times 12 = 6480

So C×12=6480C \times 12 = 6480, or £6,480 a year, on contacts alone. It is the smallest of the money leaks in this series, but it is also one of the least expensive to fix: a few DNS records, a configuration change and a quarter of an hour a month of checking. Failed password resets and lost repeat orders are not in the figure and would only make it larger.

Where the 120 contacts come from

A number like "120 extra contacts" should never be taken on trust. Here is how it follows from what the shop can observe, step by step.

Before the fix, about 6% of the order confirmations sent to Gmail and Outlook addresses landed in spam. The dispatch email with the tracking link went out the same way and fared the same. The number of messages that went missing each month follows from three figures.

M=O×m×sM = O \times m \times s

MM is the number of order messages a month that land in spam, OO is the number of orders a month whose email address is at the affected providers, mm is the number of order messages each customer actually waits for, and ss is the share of those messages that lands in spam. The method is the same as for any rate, see Foundations: ratios and rates.

Example: from 6% to 120 contacts

Of Wrenfield Home's 1,980 orders a month, 1,050 go to Gmail addresses and 600 to Outlook, Hotmail and Live addresses, so O=1650O = 1650. Each customer waits for two messages, the confirmation and the dispatch email, so m=2m = 2. With s=0.06s = 0.06:

M=1650×2×0.06=198M = 1650 \times 2 \times 0.06 = 198

So M=198M = 198: about 198 order messages a month disappear into spam folders. Not every one of them causes a contact. Some customers find the message in spam, some trust the payment and wait. The share that does write in is

q=TMq = \frac{T}{M}

where qq is the share of missing messages that cause a contact and TT is the number of extra contacts, the same kind of ratio as before (Foundations: ratios and rates). With T=120T = 120:

q=120198=0.61q = \frac{120}{198} = 0.61

About six in ten missing messages turn into a contact. That is plausible: a customer who has just paid £72 and heard nothing tends to ask. Later in this chapter Callum measures TT directly from the shop's own data, which is how the 120 is known rather than guessed.

Bar chart of the example. 1,650 orders a month go to Gmail and Outlook addresses. They receive 3,300 order messages (confirmation and dispatch). About 6%, or 198 messages, land in spam. That causes 120 extra where is my order contacts a month, costing 540 pounds. Tap or click to open full screen and move around

How a mailbox provider decides: inbox, spam or reject

To fix the leak you need a picture of what happens to a message after it leaves your shop. The receiving mailbox provider (Gmail, Outlook, Yahoo, or a smaller one) asks a series of questions within a fraction of a second, and the answers decide whether the message is rejected, goes to spam or reaches the inbox.

  • Is it really from who it says? This is authentication: SPF, DKIM and DMARC, explained in the next three sections.
  • Does this sender have a good history? This is reputation, built per sending domain and per sending server over weeks and months.
  • Do recipients want it? This is engagement and complaints: whether people open messages from this sender, move them out of spam, or press "report spam".
  • Does the message look normal? Formatting, links, whether the content looks like known spam.

Providers do not publish exactly how they weigh these. What they do publish are the minimum rules a sender must meet before the rest even matters, and those are what a shop can control. Google's sender guidelines, for example, require every sender to authenticate with SPF or DKIM, to have valid forward and reverse DNS records for the sending servers, to use Transport Layer Security (TLS) for the connection, to format messages correctly and to keep the spam rate reported in Postmaster Tools below 0.3%1.

Tap or click to open full screen and move around

Note that a failed check does not always mean rejection. Without a DMARC policy telling the receiver what to do, a message that fails authentication is not necessarily blocked. It just starts with a weaker case, and a weak case plus a newsletter that annoys people is how order confirmations end up in spam.

Example: one confirmation's journey

Callum opens one of his own test orders in a Gmail account and looks at the full message headers. Among them is a line the receiving server added, called Authentication-Results. Shortened, it reads:

Authentication-Results: mx.google.com;
       dkim=pass header.i=@mailprovider.example;
       spf=pass smtp.mailfrom=bounces.mailprovider.example;
       dmarc=fail (p=NONE) header.from=wrenfieldhome.example

Both SPF and DKIM passed, yet DMARC failed. That looks contradictory until you see the domains. The signature belongs to the email provider's domain, the bounce address belongs to the email provider's domain, and the From address the customer sees is wrenfieldhome.example. Nothing ties the shop's own name to a passing check. The message reached Gmail as "a message that claims to be from Wrenfield Home, but nobody vouches for that". The next three sections explain each part of this line.

SPF: which servers may send for your domain

SPF is a published list of the servers allowed to send mail for a domain, defined in Request for Comments (RFC) 72082, the standard of the Internet Engineering Task Force (IETF). You publish it as a text record in your Domain Name System (DNS), the internet's address book. When a message arrives, the receiving server looks up the list and checks whether the sending server is on it.

Two details trip up almost every shop.

SPF checks the bounce address, not the address the customer sees. Every message carries two sender addresses. The From address is what the customer reads. The envelope sender, also called the return path, is a technical address where bounces go. SPF checks the second one. If your email provider uses its own bounce address, SPF passes for the provider's domain, not for yours.

SPF has a hard limit of 10 DNS lookups. Each include, a, mx, ptr and exists term and the redirect modifier costs a lookup, and nested includes count too. Above 10 the result is a permanent error, which receivers treat as a failure2. Every new tool that sends mail for you (the help desk, the newsletter tool, the invoicing software) tends to add one more include, until the record quietly breaks.

Example: the record that broke on the eleventh lookup

Wrenfield Home's SPF record has grown over five years:

wrenfieldhome.example.  TXT  "v=spf1 include:_spf.google.com include:spf.oldprovider.example
  include:spf.mailprovider.example include:spf.newsletter.example include:mail.helpdesk.example
  include:servers.invoices.example a mx ~all"

Callum counts the lookups with an SPF checking tool, following every nested include. The total comes to 11. One over the limit, so every receiver that evaluates the record fully gets a permanent error, and SPF fails for every message from every one of those services. Nobody noticed, because mail still arrived most of the time.

Two of the includes are dead weight: spf.oldprovider.example belongs to the email provider the shop left two years ago, and a mx covers the web server and the mail exchanger, neither of which sends mail. Removing those three terms brings the count to 8. Moving the transactional provider and the newsletter tool to their own bounce subdomains (later in this chapter) takes two more includes out of the root record.

DKIM: a signature that proves who sent the message

DKIM, defined in RFC 63763, adds a digital signature to every message. The sending service signs certain headers and the body with a private key. It names the signing domain in the d= tag of the signature and a selector in the s= tag. The receiver fetches the matching public key from DNS at selector._domainkey.domain and checks the signature. If it checks out, two things are proven: the message was not changed on the way, and whoever controls that domain's DNS vouched for it.

The important word is "that domain". A provider can sign every message with its own domain, which proves only that the provider sent it. For the signature to speak for your shop, the provider has to sign with your domain, using a key you publish in your DNS. Every serious email provider supports this. It is usually called a custom DKIM or domain authentication, and you set it up by adding one or two DNS records the provider gives you.

Example: moving the signature to the shop's own name

In the header from the last example, header.i=@mailprovider.example shows the provider signing with its own domain. Callum opens the provider's domain settings, adds wrenfieldhome.example as a sending domain, and the provider shows him a DKIM record to publish:

wh2026._domainkey.wrenfieldhome.example.  TXT  "v=DKIM1; k=rsa; p=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA..."

wh2026 is the selector, a name Callum chose so that the key can be rotated later by adding wh2027 alongside it. Once the provider sees the record, it signs every message with d=wrenfieldhome.example. The next test order shows dkim=pass header.i=@wrenfieldhome.example. The signature now speaks for the shop.

DMARC: tying the checks to the name the customer sees

SPF and DKIM each prove something about a domain, but neither looks at the From address the customer reads. DMARC closes that gap. A message passes DMARC when SPF or DKIM passes and the domain that passed is aligned with the From domain. Alignment can be relaxed (the same organisational domain, so mail.wrenfieldhome.example aligns with wrenfieldhome.example) or strict (exactly the same name). Relaxed is the default4.

DMARC also lets the domain owner say what receivers should do with mail that fails, in a policy:

  • p=none: do nothing special, just send me reports.
  • p=quarantine: treat failing mail as suspicious, which in practice means the spam folder.
  • p=reject: refuse failing mail outright.

And it asks receivers to send aggregate reports to an address you name in the rua tag. These daily reports list, per sending server, how many messages claimed to come from your domain and whether they passed. They are the only way to see every service that sends as you, including the ones nobody remembers setting up.

DMARC was first published in 2015 as RFC 7489, an informational document. In May 2026 the IETF replaced it with three standards track documents: RFC 9989 for the protocol itself, RFC 9990 for aggregate reports and RFC 9991 for failure reports45. For a shop little changes. The records you publish look the same. The pct tag, which applied the policy to only a share of failing mail, was removed, and a new t tag (test mode) takes over part of its job: t=y asks receivers to apply one level below the stated policy while you test4. If you find pct in an old record or an old guide, that is where it went.

Example: Wrenfield Home's DMARC record, in three stages

Callum publishes the first DMARC record with no enforcement, only reporting:

_dmarc.wrenfieldhome.example.  TXT  "v=DMARC1; p=none; rua=mailto:dmarc@wrenfieldhome.example"

For four weeks the reports come in. They show four services sending as wrenfieldhome.example: Google Workspace (staff mail, passing), the transactional email provider (now passing, thanks to the new DKIM), the newsletter tool (failing, it still signs with its own domain), and the help desk tool (failing, no DKIM set up at all). Callum fixes the last two. Once the reports show close to 100% of the shop's real mail passing for two weeks, he moves on:

_dmarc.wrenfieldhome.example.  TXT  "v=DMARC1; p=quarantine; rua=mailto:dmarc@wrenfieldhome.example"

Four weeks later, with nothing legitimate failing, he sets p=reject. From then on, a fraudster who sends a fake "your order has a problem, follow this link to pay again" email in Wrenfield Home's name gets it refused by every receiver that honours DMARC. The order confirmations, meanwhile, arrive with a clean, aligned pass.

RecordNameValue at the end of the workWhat it does
SPF, rootwrenfieldhome.examplev=spf1 include:_spf.google.com include:mail.helpdesk.example ~allLists the servers allowed to send with a root bounce address
SPF, transactional bouncesbounces.wrenfieldhome.exampleA CNAME to the provider, as its documentation saysMakes SPF pass and align for order emails
DKIM, transactionalwh2026._domainkey.wrenfieldhome.exampleThe public key from the providerSigns order emails with the shop's own name
DKIM, newslettera selector under news.wrenfieldhome.exampleThe public key from the newsletter toolSigns the newsletter with its own subdomain
DMARC_dmarc.wrenfieldhome.examplev=DMARC1; p=reject; rua=mailto:dmarc@wrenfieldhome.exampleTells receivers to refuse anything that fails, and to report

The domains ending in .example are stand ins. Your email provider's documentation gives the exact names and values to publish. The include for Google Workspace is the one Google publishes for its own servers6.

The rules Google, Yahoo and Microsoft now enforce

Until 2024 all of this was good practice. Then the largest mailbox providers turned it into rules. Google and Yahoo announced requirements that took effect from February 202417, and Microsoft followed for Outlook.com, Hotmail.com and Live.com from 5 May 20258. The rules split senders into two groups.

RuleAll senders to GmailBulk senders to Gmail and YahooHigh volume senders to Outlook.com
AuthenticationSPF or DKIMSPF and DKIM, bothSPF and DKIM, both must pass
DMARCNot requiredPublished, at least p=nonePublished, at least p=none
AlignmentNot requiredFrom domain aligned with SPF or DKIMAligned with SPF or DKIM, ideally both
Spam rateBelow 0.3% in Postmaster ToolsBelow 0.3%, Google asks for below 0.1%No figure stated
UnsubscribeNot requiredOne click unsubscribe in marketing and subscribed messagesA working unsubscribe link recommended
Unsubscribe processingNot requiredWithin two daysNot stated
DNS and transportValid forward and reverse DNS, TLSThe sameNot stated in the announcement

Sources for the table: Google19, Yahoo7 and Microsoft8.

Three details matter for a shop.

Who counts as a bulk sender. Google defines a bulk sender as one that sends close to 5,000 messages or more to personal Gmail accounts in a day, counted across everything sent from the same primary domain. Once a domain crosses that line, the status is permanent: "Bulk sender status doesn't have an expiration date"9. Microsoft's threshold is more than 5,000 messages a day to its consumer domains8.

The spam rate is measured on complaints. It is the share of delivered messages that recipients mark as spam, as Postmaster Tools reports it. Google asks senders to stay below 0.1% and never to reach 0.3%1. Bulk senders above 0.3% lose access to Google's mitigation support until the rate has stayed below 0.3% for seven days in a row9.

Enforcement is real and has been getting stricter. Google's FAQ says that from November 2025 Gmail is ramping up enforcement on traffic that does not comply, including temporary and permanent rejections9. Microsoft's announcement says that after 5 May 2025 Outlook routes mail from high volume domains that do not comply to the Junk folder, with rejection to follow at a later date, which at the time of writing Microsoft had not announced8.

Transactional messages such as order confirmations do not need an unsubscribe link9. But they are sent from the same domain as everything else, and that is where the trap lies.

Example: is Wrenfield Home a bulk sender?

The shop itself sends about 4,000 order emails a month, nowhere near 5,000 a day. But the newsletter goes to 38,000 people from the same root domain, and about 20,500 of them have Gmail addresses (the example's figure). On every newsletter day the domain sends more than 20,000 messages to Gmail. So wrenfieldhome.example crossed the bulk sender line the first time the newsletter went out, and it stays a bulk sender for good. Every rule in the right hand column applies to it, including to the order confirmations, because they come from the same domain.

The complaint rate, and why the newsletter decides the fate of the order emails

Mailbox providers build reputation per domain. If the newsletter annoys people, the complaints count against the domain, and the order confirmations from that same domain pay for it. This is the mechanism behind most order emails in spam: not a problem with the order emails, but with the other mail sent in the same name.

The complaint rate is a simple share. Foundations: ratios and rates covers the idea.

r=kdr = \frac{k}{d}

rr is the complaint rate, kk is the number of recipients who marked a message as spam, and dd is the number of messages delivered to that provider.

Example: one newsletter, 82 complaints

Postmaster Tools shows that the last newsletter was delivered to 20,500 Gmail inboxes and drew 82 spam reports.

r=8220500=0.0040r = \frac{82}{20500} = 0.0040

So r=0.40%r = 0.40\%, above Google's 0.3% ceiling and four times its 0.1% target. Callum looks for the cause. The list includes about 9,000 people who have not opened a single newsletter in over a year, many of them past customers who were added at checkout years ago and forgot. To them the newsletter looks like spam, and the quickest way out is the spam button, because the unsubscribe link is a small grey line at the bottom.

Two changes follow, both covered in the next sections: a one click unsubscribe that the mailbox provider can show as a button at the top of the message, and a newsletter that only goes to people who opened one in the last 12 months, with a single "do you still want this?" message to everyone else. Three newsletters later the complaint rate at Gmail is 0.08%.

One click unsubscribe, done properly

The one click unsubscribe the bulk sender rules require is defined in RFC 805810, building on the List-Unsubscribe header from RFC 236911. A marketing message carries two headers:

List-Unsubscribe: <https://wrenfieldhome.example/email/unsubscribe/eyJfcmFpbHMiOnsi...>
List-Unsubscribe-Post: List-Unsubscribe=One-Click

The mailbox provider shows an unsubscribe button. When the recipient presses it, the provider sends an HTTPS POST to that address with the body List-Unsubscribe=One-Click. RFC 8058 sets the rules for the receiving end10:

  • The List-Unsubscribe header must contain one HTTPS address, and the message must carry a valid DKIM signature that covers both headers.
  • The POST carries no cookies and no login, so the address itself must identify the subscriber, usually with a signed token.
  • The sender must not answer with a redirect.

The reason this protects the order emails: a person who can unsubscribe with one press does not need the spam button. Every unsubscribe that replaces a complaint takes weight off the domain's reputation.

Example: the back in stock email from the Rails app

Most newsletter tools add these headers themselves. But Wrenfield Home's Rails app also sends its own marketing messages, such as "back in stock" alerts that customers ask for on a product page. Those need the headers too. Rails can generate a signed, tamper proof token for a record with generates_token_for, available on Active Record models since Rails 7.112. The marketing_opt_in column is one the shop added to its users table.

# app/models/spree/user_unsubscribe_token.rb (loaded with the app's other Solidus overrides)
module Spree
  module UserUnsubscribeToken
    def self.prepended(base)
      base.generates_token_for :unsubscribe
    end

    Spree::User.prepend self
  end
end

# app/mailers/marketing_mailer.rb
class MarketingMailer < ApplicationMailer
  default from: "Wrenfield Home <hello@news.wrenfieldhome.example>"

  def back_in_stock(user, variant)
    @variant = variant
    url = unsubscribe_one_click_url(token: user.generate_token_for(:unsubscribe))

    headers["List-Unsubscribe"] = "<#{url}>"
    headers["List-Unsubscribe-Post"] = "List-Unsubscribe=One-Click"

    mail(to: user.email, subject: "#{variant.name} is back in stock")
      .tap { |message| message.message_stream = "broadcast" }
  end
end

The route and the controller answer the provider's POST without a login and without a redirect, and show a normal confirmation page to anyone who opens the link in a browser.

# config/routes.rb
post "/email/unsubscribe/:token", to: "unsubscribes#one_click", as: :unsubscribe_one_click
get  "/email/unsubscribe/:token", to: "unsubscribes#show"

# app/controllers/unsubscribes_controller.rb
class UnsubscribesController < ApplicationController
  # Mailbox providers post without a session, so there is no CSRF token to check
  skip_forgery_protection only: :one_click

  def one_click
    user = Spree::User.find_by_token_for(:unsubscribe, params[:token])
    user&.update!(marketing_opt_in: false)
    head :ok # no redirect, as RFC 8058 requires
  end

  def show
    @user = Spree::User.find_by_token_for(:unsubscribe, params[:token])
  end
end

The message_stream line sends this message through the provider's broadcast stream, which is the subject of the next section. The message_stream= method comes from the postmark gem that the postmark-rails delivery method is built on13. With another provider the same idea is a different header or setting, documented by that provider.

Keep order emails apart from marketing

The most effective structural fix is separation. Order confirmations, dispatch emails and password resets are messages every customer wants. Newsletters and promotions are messages some customers tolerate. Sending both through the same pipe, from the same address, lets the second drag down the first.

Separation works on three levels.

  • Separate streams at the provider. Postmark, for example, splits sending into transactional and broadcast message streams that run on separate sending infrastructure, and recommends keeping the two types on separate streams and subdomains, each with its own DKIM and return path14. Other providers, Amazon SES among them, offer comparable ways to separate traffic, each in its own terms. The guide to safe transactional email with Postmark, Rails and Solidus shows that setup step by step.
  • Separate subdomains. Marketing from news.wrenfieldhome.example, order mail from the root domain with its bounces at bounces.wrenfieldhome.example. Each subdomain builds its own record of behaviour that a receiver can tell apart, and your DMARC reports show each one separately.
  • Separate tools, separate jobs. The newsletter tool sends the newsletter. The shop's transactional provider sends order mail. Staff mail goes through Google Workspace or Microsoft 365. None of them borrows another's address.

Separation does not make bad marketing safe. All the subdomains still sit under one organisational domain, and a very poor newsletter can still affect the whole name. What it does is stop an ordinary bad week in marketing from reaching the customer who just paid.

Example: the new layout at Wrenfield Home

MailFrom addressSent throughSigned with (DKIM d=)
Order confirmation, dispatch, refundorders@wrenfieldhome.exampleTransactional provider, transactional streamwrenfieldhome.example
Password reset, account emailsorders@wrenfieldhome.exampleTransactional provider, transactional streamwrenfieldhome.example
Back in stock alertshello@news.wrenfieldhome.exampleTransactional provider, broadcast streamnews.wrenfieldhome.example
Newsletterhello@news.wrenfieldhome.exampleNewsletter toolnews.wrenfieldhome.example
Help desk replieshelp@wrenfieldhome.exampleHelp desk toolwrenfieldhome.example
Staff mailnamed staff addressesGoogle Workspacewrenfieldhome.example

Every row passes DMARC with alignment. The two rows that carry marketing sit on their own subdomain and their own stream. The newsletter's complaints now show up under news.wrenfieldhome.example in Postmaster Tools, where Priya can see them without them colouring the order mail.

What the Rails and Solidus app actually sends

A developer needs to know where each message starts, because that is where the From address and the sending route are decided. In a Solidus shop the core messages are:

  • The order confirmation. When an order is finalised, Solidus publishes an order_finalized event. A subscriber, Spree::OrderConfirmationMailerSubscriber, calls confirm_email on the configured order mailer, deliver_later, and sets the order's confirmation_delivered column to true15.
  • The dispatch email. Spree::CartonMailer#shipped_email goes out when a carton is shipped, with the tracking details.
  • The password reset. With the solidus_auth_devise extension, Spree::UserMailer#reset_password_instructions sends the reset link16.

All of them take their From address from the store: Spree::BaseMailer#from_address returns store.mail_from_address. The base mailer also sends nothing at all when Spree::Config.send_core_emails is false17. The route the message takes is Rails' Action Mailer configuration, usually config.action_mailer.delivery_method in the production environment file18.

One detail is worth a developer's attention. confirmation_delivered sounds like a delivery receipt, but the subscriber sets it as soon as the email job is queued15. It means "handed to the background queue", not "accepted by the provider", and certainly not "in the customer's inbox". A shop that reads it as proof of delivery will never see this leak in its own database.

Example: Callum's two tests

Callum works test first. Before touching the configuration he writes two tests that describe the result he wants, watches them fail, then makes them pass. The first pins the order confirmation to the shop's own domain, so a future change to the store settings cannot quietly send it from an address that does not align. The second pins the marketing email to the broadcast stream with a working one click unsubscribe.

# spec/mailers/email_routing_spec.rb
require "rails_helper"

RSpec.describe "email routing" do
  it "sends the order confirmation from the shop's own domain" do
    order = create(:completed_order_with_totals)

    mail = Spree::OrderMailer.confirm_email(order)

    expect(mail.from.first).to end_with("@wrenfieldhome.example")
  end

  it "sends back in stock alerts on the broadcast stream with one click unsubscribe" do
    user = create(:user)

    mail = MarketingMailer.back_in_stock(user, create(:variant))

    expect(mail.message_stream).to eq("broadcast")
    expect(mail["List-Unsubscribe-Post"].value).to eq("List-Unsubscribe=One-Click")
    expect(mail["List-Unsubscribe"].value).to start_with("<https://")
  end
end

The first test fails at once: the store's mail_from_address is still shop@wrenfieldhomeshop.example, a domain from the shop's first year that nobody uses any more. That single setting explains why the confirmations never aligned, whatever the DNS said. Callum changes it in the store settings, adds it to the seed data so a fresh environment gets the right value, and both tests pass. Every release goes through the test gate, so the next person who changes the store settings will find out from a failing test rather than from Priya's Monday inbox.

Finding the leak in your own data

No report anywhere tells you "6% of your order emails went to spam". Mailbox providers do not report where a delivered message was filed. So you build the picture from four sources, each of which shows one side of it.

  1. Your customer service tickets, joined to your orders. The cost of the leak shows up here first.
  2. Your email provider's events. Bounces, deferrals and the complaints that providers report back.
  3. DMARC aggregate reports. Who sends in your name, and whether it passes.
  4. Google Postmaster Tools. Your domain's spam rate at Gmail, and whether Google considers you compliant with its requirements19.

A fifth check needs no data at all: a test order to a few accounts you keep at Gmail, Outlook and Yahoo, read with the full headers, as in the earlier example.

Example: where is my order contacts per 100 orders, by mailbox provider

Callum loads the customer service tool's ticket export into a table, support_tickets, next to the shop's database. The query below, in PostgreSQL, takes last month's completed orders, groups them by the customer's mailbox provider, and counts how many were followed by a "where is my order" ticket within a week. Email addresses are trimmed and lowercased before the join, because 3.1% of the shop's customer accounts are known duplicates that differ only in case or spaces.

-- PostgreSQL: orders followed by a "where is my order" ticket, by mailbox provider, last full month
WITH orders AS (
  SELECT o.id,
         lower(trim(o.email)) AS email
  FROM spree_orders o
  WHERE o.state = 'complete'
    AND o.completed_at >= date_trunc('month', now()) - interval '1 month'
    AND o.completed_at <  date_trunc('month', now())
),
tagged AS (
  SELECT orders.*,
         CASE
           WHEN split_part(email, '@', 2) IN ('gmail.com', 'googlemail.com') THEN 'Gmail'
           WHEN split_part(email, '@', 2) IN ('outlook.com', 'hotmail.com', 'hotmail.co.uk',
                                               'live.com', 'live.co.uk', 'msn.com') THEN 'Outlook'
           ELSE 'Other'
         END AS mailbox
  FROM orders
),
wismo AS (
  SELECT DISTINCT lower(trim(t.requester_email)) AS email
  FROM support_tickets t
  WHERE t.tag = 'where-is-my-order'
    AND t.created_at >= date_trunc('month', now()) - interval '1 month'
    AND t.created_at <  date_trunc('month', now()) + interval '7 days'
)
SELECT mailbox,
       count(*)                                    AS orders,
       count(w.email)                              AS orders_with_ticket,
       round(100.0 * count(w.email) / count(*), 1) AS per_100_orders
FROM tagged
LEFT JOIN wismo w USING (email)
GROUP BY mailbox
ORDER BY per_100_orders DESC;

The result for the month before the fix:

mailboxordersorders_with_ticketper_100_orders
Gmail1,05018417.5
Outlook6008614.3
Other330309.1

If customers simply liked to ask, the rate would be similar everywhere. It is not. Customers at "other" providers, where the shop's mail was not being filtered the same way, write in 9.1 times per 100 orders. That is the baseline: the contacts a shop gets anyway, for late parcels and genuine questions. Everything above it at Gmail and Outlook is the email leak. The excess is

E=Tp−Op×bE = T_{p} - O_{p} \times b

where EE is the number of excess contacts at a provider, TpT_{p} is the contacts observed there, OpO_{p} is the orders to that provider and bb is the baseline rate per order from the unaffected providers. As always, Foundations: ratios and rates has the groundwork. With b=30÷330=0.0909b = 30 \div 330 = 0.0909:

EGmail=184−1050×0.0909=88.5E_{\text{Gmail}} = 184 - 1050 \times 0.0909 = 88.5

For Gmail E=88.5E = 88.5 excess contacts. The same for Outlook:

EOutlook=86−600×0.0909=31.5E_{\text{Outlook}} = 86 - 600 \times 0.0909 = 31.5

Together 88.5+31.5=12088.5 + 31.5 = 120 contacts a month. That is where the 120 in this chapter comes from: measured, not assumed. Two cautions. Customers with their own domain may still use Google or Microsoft behind it, so a few affected customers hide in "other", which makes the estimate a little conservative. And a provider in "other" can have its own problem, so check that its rate looks like the shop's long run average before you use it as the baseline.

Example: reading a month of DMARC reports

DMARC aggregate reports arrive as compressed XML files, one per receiver per day. Reading them by eye is slow, so Callum writes a short Python script with the standard library's ElementTree. The {*} in each path matches the element with or without an XML namespace, because reports written to the new RFC 9990 format carry one and older ones do not520.

# Summarise DMARC aggregate reports (XML files, unzipped into ./dmarc)
from collections import Counter
from pathlib import Path
import xml.etree.ElementTree as ET

totals = Counter()
for path in Path("dmarc").glob("*.xml"):
    root = ET.parse(path).getroot()
    org = root.findtext("{*}report_metadata/{*}org_name")
    for record in root.iterfind("{*}record"):
        row = record.find("{*}row")
        count = int(row.findtext("{*}count"))
        ip = row.findtext("{*}source_ip")
        dkim = row.findtext("{*}policy_evaluated/{*}dkim")
        spf = row.findtext("{*}policy_evaluated/{*}spf")
        result = "pass" if "pass" in (dkim, spf) else "fail"
        totals[(org, ip, result)] += count

for (org, ip, result), count in totals.most_common(8):
    print(f"{org:<13} {ip:<15} {result:<5} {count:>6}")

The output for the first four weeks, with the addresses taken from the ranges reserved for documentation:

google.com    203.0.113.21    pass    3150
google.com    198.51.100.40   fail    2760
Outlook.com   203.0.113.21    pass    1290
google.com    192.0.2.14      fail     610
Outlook.com   198.51.100.40   fail     540
Yahoo         203.0.113.21    pass     240
google.com    192.0.2.77      pass     180
Outlook.com   192.0.2.14      fail     130

Callum looks up each address. 203.0.113.21 is the transactional provider, passing since the new DKIM went live. 198.51.100.40 is the newsletter tool, failing because it still signs with its own domain. 192.0.2.14 is the help desk tool, failing with no DKIM at all. 192.0.2.77 is Google Workspace. Two services, about 4,000 messages a month, were sending in the shop's name without passing DMARC. Neither had anything to do with order confirmations, and both were dragging the domain's reputation down.

The fix, in the order that works

Changing DNS records in the wrong order can block your own mail, so the sequence matters. This is the order I would follow for any shop, and it is the order Callum followed.

Tap or click to open full screen and move around
  1. Inventory. List every service that sends mail with your domain in the From address: shop, newsletter, help desk, invoicing, reviews, staff mail. Ask whoever set up each one. The DMARC reports will later show what you missed.
  2. Authenticate the order mail first. Set up DKIM with your own domain and a custom bounce (return path) subdomain at the transactional provider. Check store.mail_from_address. Send a test order and read the headers.
  3. Publish DMARC with p=none and an rua address. A dedicated mailbox, or a DMARC report service if you would rather not read XML.
  4. Read the reports for at least four weeks. Every service that fails gets its own DKIM set up, or stops sending in your name.
  5. Separate marketing. Its own subdomain, its own stream or tool, one click unsubscribe, and a list that only contains people who still want it.
  6. Enforce. Move DMARC to p=quarantine and, once the reports stay clean, to p=reject.
  7. Clean up SPF. Remove services you no longer use, stay well under 10 lookups.

Example: eight weeks at Wrenfield Home

Week one: inventory, DKIM and bounce subdomain for the transactional provider, the mail_from_address fix, DMARC at p=none. Weeks two to five: the reports reveal the newsletter tool and the help desk. Callum sets up DKIM for both and moves the newsletter to news.wrenfieldhome.example. Week five: the SPF record goes from 11 lookups to 6. Week six: one click unsubscribe in the newsletter tool and the Rails app, and the inactive part of the list gets a single message asking whether they still want the newsletter, after which those who do not answer are removed. Week eight: DMARC to p=quarantine, and a month later p=reject.

The ticket query, run again for the first full month after week eight:

mailboxordersorders_with_ticketper_100_orders
Gmail1,050969.1
Outlook600549.0
Other330309.1

The rates have converged on the baseline. "Where is my order" contacts fell from 300 a month to 180, exactly the 120 the excess calculation predicted. At £4.50 each that is the £540 a month and £6,480 a year from the start of this chapter, recovered with DNS records, a store setting and a few dozen lines of Ruby.

Grouped bar chart of the example. Before the fix, contacts per 100 orders were 17.5 for Gmail, 14.3 for Outlook and 9.1 for other providers. After the fix they were 9.1, 9.0 and 9.1. Total contacts fell from 300 to 180 a month, 120 fewer, worth 540 pounds a month. Tap or click to open full screen and move around

BIMI: the logo comes last

Brand Indicators for Message Identification (BIMI) lets a mailbox show your logo next to your messages. It is optional, and it is a reward for finishing the work above, not a shortcut around it. The BIMI Group's implementation guide lists the prerequisites: DMARC at enforcement (p=quarantine or p=reject) on the domain and its subdomains, a logo in a restricted SVG format called SVG Tiny PS, a BIMI record in DNS, and for most mailboxes a Verified Mark Certificate (VMC), which requires a registered trademark, or a Common Mark Certificate (CMC)21.

For a shop the size of Wrenfield Home, BIMI is a nice finish once DMARC has been at p=reject for a while. It will not move an order confirmation out of spam on its own, because a domain that qualifies for BIMI has already done the things that do.

Example: is BIMI worth it for Priya?

Priya's logo is not a registered trademark, so a VMC is out until it is. A CMC needs no trademark. Callum estimates the work at an afternoon for the SVG and the DNS record, plus the cost of the certificate. Priya decides to wait until the trademark application she has been meaning to file anyway is through. The order emails do not need it: they already reach the inbox.

The law around these emails, briefly

This section is general information, not legal advice. Two pieces of UK law touch the emails in this chapter.

The order acknowledgement is a legal duty, not a courtesy. Under regulation 11 of the Electronic Commerce (EC Directive) Regulations 2002, a shop must acknowledge receipt of an order without undue delay and by electronic means. The acknowledgement is deemed received when the customer is able to access it22. Whether a message in a spam folder counts as accessible is a question for a lawyer. The commercial cost in this chapter exists either way.

Marketing email needs consent or the soft opt in. Regulation 22 of the Privacy and Electronic Communications Regulations 2003 (PECR) allows direct marketing by email only with prior consent, or to existing customers about similar products when they had a simple way to refuse at the time and in every message23. The regulator is the Information Commission (formerly the Information Commissioner's Office, ICO). Shops get this wrong most often by adding every buyer to the newsletter without that chance to refuse, which is exactly the kind of list that produces spam complaints. A later article in this programme covers email and text messages as a marketing channel in full, including consent.

Example: the checkout tick box

Wrenfield Home's checkout used to add every customer to the newsletter. Callum replaces that with an unticked box, "Send me the newsletter, I can unsubscribe in one click", and the soft opt in wording on the order confirmation. Fewer people join the list. The ones who do want it, which is the point for the law and for the complaint rate alike.

A check to repeat every quarter

Email setups decay. Someone adds a new tool, a key expires, a provider changes its bounce domain, a store setting is edited. A quarterly check of about 15 minutes catches it before customers do.

CheckWhereHealthyAct when
"Where is my order" contacts per 100 orders, by mailbox providerTicket export joined to orders (the SQL above)Gmail and Outlook within 1 point of "other"Any provider 2 points above "other"
Gmail spam rate, per domain and subdomainGoogle Postmaster ToolsBelow 0.1%0.1% or above, urgently at 0.3%
Compliance statusGoogle Postmaster ToolsAll requirements compliantAnything marked as needing work
DMARC pass rate for your real sendersDMARC reports (the script above)99% or moreAny new sending source, or a known one failing
SPF lookupsAn SPF checking tool8 or fewer9 or more
Test order to Gmail, Outlook, Yahoo accountsFull headersdkim, spf and dmarc all pass, alignedAny fail
Password reset testSame test accountsArrives in the inbox within a minuteSpam or delay
store.mail_from_address and DMARC policySolidus admin, DNSOwn domain, p=rejectAnything else

Example: the first quarter after the fix

Three months after the fix Callum runs the check. Gmail and Outlook sit at 9.3 and 9.0 contacts per 100 orders against 8.9 for other providers. The Gmail spam rate is 0.05% for the root domain and 0.09% for news.wrenfieldhome.example. The DMARC reports show one new source: the review platform Priya signed up with last month, sending review requests as wrenfieldhome.example and failing, so the shop's own policy now has them refused. Priya had been wondering why so few customers left reviews. Callum sets up the review platform on the news subdomain with its own DKIM, and the review requests start arriving. Fifteen minutes, one leak caught before it cost anything.

My view

Email deliverability is usually filed under marketing, and that is why order confirmations end up in spam. The person who owns the newsletter cares about opens and clicks. Nobody owns the confirmation, because it "just works". In my view the order confirmation, the dispatch email and the password reset are part of the checkout, and they deserve the same care as the payment step: tested, monitored, and protected from anything that could drag them down. Concretely, that means order mail on its own stream with its own aligned signature, marketing on its own subdomain, DMARC at p=reject within three months, and the newsletter list cut to people who actually read it. The first three are an afternoon of work for a developer. The last is a decision for the owner, and it is the one that protects everything else.

I build shops on Ruby on Rails and Solidus, and I treat these messages the way I treat any other part of a release: they have tests, they go through the test gate, and they show up in the quarterly check. The shop, its domain and its email accounts belong to the owner, not to whoever set them up.

Conclusion

A shop's own emails landing in spam is a quiet leak because every system reports success: the order is complete, the payment is captured, the mailer says "delivered". The only visible symptom is a steady flow of "where is my order" contacts, plus password resets and repeat orders that never happen. In the example it costs 120 extra contacts a month, £540 a month and £6,480 a year on contacts alone.

The cause is almost always one of a few things: order mail that is not signed with the shop's own domain, a DMARC record that is missing or never enforced, an SPF record over its lookup limit, and marketing mail sent in the same name that collects spam complaints. The rules of Google, Yahoo and Microsoft now make the first two mandatory for any shop that sends a newsletter of a few thousand people. The fix runs in a fixed order: inventory, authenticate the order mail, DMARC with reports, fix every sender, separate marketing, enforce. Then measure the leak where it shows, by joining support tickets to orders by mailbox provider, and repeat that check every quarter.

Want to know whether your own order emails reach the inbox, and what the misses cost you? Book the free workshop and we will check your setup together, and the first two weeks of work are on me.

Sources

  1. 1.

    Google, Email sender guidelines, Gmail Help (Google Workspace Admin Help), https://support.google.com/a/answer/81126

  2. 2.

    S. Kitterman, Sender Policy Framework (SPF) for Authorizing Use of Domains in Email, Version 1, RFC 7208, IETF, April 2014, section 4.6.4 on DNS lookup limits, https://www.rfc-editor.org/rfc/rfc7208

  3. 3.

    D. Crocker, T. Hansen and M. Kucherawy (editors), DomainKeys Identified Mail (DKIM) Signatures, RFC 6376, IETF, September 2011, https://www.rfc-editor.org/rfc/rfc6376

  4. 4.

    T. Herr and J. Levine (editors), Domain-Based Message Authentication, Reporting, and Conformance (DMARC), RFC 9989, IETF, May 2026 (obsoletes RFC 7489 and RFC 9091; tags in section 4.7, removal of pct in appendix A.6), https://www.rfc-editor.org/rfc/rfc9989

  5. 5.

    A. Brotman (editor), Domain-Based Message Authentication, Reporting, and Conformance (DMARC) Aggregate Reporting, RFC 9990, IETF, May 2026, https://www.rfc-editor.org/rfc/rfc9990

  6. 6.

    Google, Set up SPF, Google Workspace Admin Help, https://knowledge.workspace.google.com/admin/security/set-up-spf

  7. 7.

    Yahoo, Sender best practices, Yahoo Sender Hub, https://senders.yahooinc.com/best-practices/

  8. 8.

    Microsoft, Strengthening Email Ecosystem: Outlook's New Requirements for High-Volume Senders, Microsoft Defender for Office 365 Blog, published 2 April 2025, updated 30 April 2025, https://techcommunity.microsoft.com/blog/microsoftdefenderforoffice365blog/strengthening-email-ecosystem-outlook%E2%80%99s-new-requirements-for-high%E2%80%90volume-senders/4399730

  9. 9.

    Google, Email sender guidelines FAQ, Google Workspace Admin Help, https://support.google.com/a/answer/14229414

  10. 10.

    J. Levine and T. Herkula, Signaling One-Click Functionality for List Email Headers, RFC 8058, IETF, January 2017, https://www.rfc-editor.org/rfc/rfc8058

  11. 11.

    G. Neufeld and J. Baer, The Use of URLs as Meta-Syntax for Core Mail List Commands and their Transport through Message Header Fields, RFC 2369, IETF, July 1998, https://www.rfc-editor.org/rfc/rfc2369

  12. 12.

    Ruby on Rails API documentation, ActiveRecord::TokenFor::ClassMethods (generates_token_for, find_by_token_for), https://api.rubyonrails.org/classes/ActiveRecord/TokenFor/ClassMethods.html

  13. 13.

    ActiveCampaign, postmark gem, lib/postmark/message_extensions/mail.rb (message_stream accessor), GitHub, https://github.com/ActiveCampaign/postmark-gem/blob/main/lib/postmark/message_extensions/mail.rb

  14. 14.

    Postmark, How to create and send through Message Streams, Postmark Support, https://postmarkapp.com/support/article/1207-how-to-create-and-send-through-message-streams

  15. 15.

    Solidus, Spree::OrderConfirmationMailerSubscriber, core/app/subscribers/spree/order_confirmation_mailer_subscriber.rb, GitHub, https://github.com/solidusio/solidus/blob/main/core/app/subscribers/spree/order_confirmation_mailer_subscriber.rb

  16. 16.

    Solidus, solidus_auth_devise, app/mailers/spree/user_mailer.rb, GitHub, https://github.com/solidusio/solidus_auth_devise/blob/main/app/mailers/spree/user_mailer.rb

  17. 17.

    Solidus, Spree::BaseMailer, core/app/mailers/spree/base_mailer.rb, GitHub, https://github.com/solidusio/solidus/blob/main/core/app/mailers/spree/base_mailer.rb

  18. 18.
  19. 19.

    Google, Postmaster Tools dashboards, Gmail Help, https://support.google.com/a/answer/14668346

  20. 20.

    Python documentation, xml.etree.ElementTree, the ElementTree XML API (namespace wildcard {*} in paths, since Python 3.8), https://docs.python.org/3/library/xml.etree.elementtree.html

  21. 21.

    BIMI Group, BIMI implementation guide, https://bimigroup.org/implementation-guide/

  22. 22.

    The Electronic Commerce (EC Directive) Regulations 2002, regulation 11, legislation.gov.uk, https://www.legislation.gov.uk/uksi/2002/2013/regulation/11

  23. 23.

    The Privacy and Electronic Communications (EC Directive) Regulations 2003, regulation 22, legislation.gov.uk, https://www.legislation.gov.uk/uksi/2003/2426/regulation/22