Skip to main content
Mailgun is a long-established email API with flexible routing and a choice of US or EU infrastructure. The EU region makes it a common pick for stores that need their email data to stay in Europe. Spree talks to Mailgun over plain SMTP, so there is nothing to install — see Emails for how the configuration works.

Configuration

The username is a full address at your Mailgun sending domain, usually the postmaster@ mailbox Mailgun creates for you. Pick the right region. Mailgun runs the US and EU as separate infrastructure, and an account in one is invisible to the other: Mailgun listens on ports 25, 587 and 2525 for STARTTLS, and 465 for implicit TLS, which Spree does not use. Mailgun recommends 587, since some ISPs block or throttle port 25.

Getting SMTP credentials

Credentials are set per domain, not per account:
  1. In the Mailgun dashboard, open your sending domain’s settings.
  2. Find its SMTP credentials.
  3. Copy the username, and reset the password to reveal a new one.
Because each domain has its own credentials, make sure the ones you use match the domain in SMTP_FROM_ADDRESS.

Authenticating your domain

Add your sending domain under Sending → Domains. Mailgun asks for TXT records for SPF and DKIM, and CNAME records for tracking. Most setups use a subdomain such as mg.yourstore.com, which keeps Mailgun’s records away from your main domain’s mail. Once the domain verifies, set SMTP_FROM_ADDRESS to an address on it.
The sandbox domain only emails people you list. Every new account gets a sandbox….mailgun.org domain that can send only to authorized recipients, capped at five addresses, each of which must accept an invitation. It is for testing — a store using the sandbox silently fails to reach every customer. Add and verify your own domain, and point SMTP_HOST, the credentials and SMTP_FROM_ADDRESS at it before taking orders.