How to Send Emails from Shopify Flow Using Mailgun
What You'll Need
- A Shopify store on a plan that includes Shopify Flow
- FlowRelay installed on your store
- A Mailgun account with a verified sending domain and access to your domain’s DNS settings
Step 1Create a Mailgun Account
Go to mailgun.com and sign up for an account.
The Free plan tops out at 100 emails a day on a single custom domain (its sandbox domain can only reach addresses you’ve explicitly authorized), which is enough to get FlowRelay connected and tested. Paid plans start with Basic at around $15/mo for 10,000 emails, with Foundation and Scale tiers above that for higher volume. Check mailgun.com/pricing for current numbers before you commit to real volume.
Step 2Add and Verify Your Sending Domain
In the Mailgun dashboard, open Sending → Domains and add the domain you want to send from (a subdomain such as mg.yourstore.com works well and keeps Mailgun’s records separate from your main domain’s mail setup).
Mailgun hands you two TXT records to add through your domain registrar or DNS host: one for SPF and one for DKIM. It also offers a CNAME record for open and click tracking, which is worth adding too. Once they’re saved, click Verify DNS Settings on the domain’s page. Propagation is often quick, but DNS changes can take up to 24 to 48 hours to fully take effect.
Step 3Generate an API Key
Open Settings → API Keys in the Mailgun dashboard. You can use the account’s existing Private API key or create a new one.
Copy the key somewhere safe as soon as you can see it: it’s a long string that typically starts with key- followed by a hex string. FlowRelay uses this key to authenticate every request it sends to Mailgun’s API on your behalf.
Step 4Install FlowRelay on Your Shopify Store
Install FlowRelay from the Shopify App Store and accept the requested permissions.
On first launch, FlowRelay shows a short setup checklist: set your sender name and email, connect a provider, and send a test email. The next step covers connecting Mailgun.
Step 5Connect Mailgun to FlowRelay
In FlowRelay, open Settings, find Email delivery, and click Manage providers to open the Connect email provider dialog.
Pick Mailgun from the provider list and fill in the API key you generated, the sending domain you verified (such as mg.yourstore.com), and the Region your domain lives in (US or EU, matching what you chose when you added the domain in Mailgun, since the two run on separate API endpoints). If you want emails to go out under a different name or address than your account default, open Override sender and fill those in, and turn on open or click tracking if you’d like Mailgun to report on those events.
Click Connect. Whichever provider you connect first becomes your Primary, and FlowRelay routes all outbound mail through it. You can connect a second provider later as an automatic Fallback.
Step 6Create Your First Flow Trigger
Open Shopify Flow, create a new workflow, and pick a trigger (Order created is a common one to start with). Add the Send transactional email action; it shows up in the action list once FlowRelay is installed.
You’ll need to fill in a few fields on the action: an email address for the recipient (this can pull straight from the trigger, like the customer’s email), a subject line, and the body, which is the actual HTML content of the email. There’s also an optional preview text field for the snippet shown in inbox previews. For the body, you can write plain HTML or use Liquid to pull in order details, customer names, and other data from the workflow.
Save the workflow and turn it on.
Step 7Test Your Setup
Before you trust a live trigger, use the Send test email button in FlowRelay’s settings. It confirms Mailgun is wired up correctly and shows you where the message lands.
Once that test email arrives, run your Flow workflow under real conditions, like placing a test order, and check FlowRelay’s delivery log to confirm the email went out through Mailgun and see its delivery status.
Common Issues
“Invalid API key.”
- FlowRelay shows this when Mailgun rejects the key outright (a 401 response). Open Settings → API Keys in Mailgun, copy the key again, and watch for missing characters or extra whitespace
- If the key was deleted or regenerated in Mailgun, copy the current one and reconnect it in FlowRelay’s provider settings
“Domain not found: mg.yourstore.com”
- Open Sending → Domains in Mailgun and check that the domain name there matches exactly what you entered in FlowRelay, subdomain and all
- Recheck the Region you picked in FlowRelay. A domain added under the EU region won’t be found through the US API, and vice versa
- If the domain isn’t listed at all, add it in Mailgun and finish DNS verification before connecting it to FlowRelay
“Domain sandboxXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.mailgun.org is not allowed to send: Free accounts are for test purposes only. Please upgrade or add the address to your authorized recipients.”
- This means FlowRelay is pointed at Mailgun’s sandbox domain rather than a domain of your own. Sandbox domains can only deliver to addresses you’ve explicitly authorized
- Add and verify your own sending domain in Mailgun (see step 2), then update the Sending domain field in FlowRelay’s provider settings to match it
- While you’re still on the sandbox domain, add the recipient under Sending → Domains → (your sandbox domain) → Authorized Recipients and confirm it through the email Mailgun sends
- Upgrading to a paid Mailgun plan removes the authorized-recipients restriction entirely
“‘from’ parameter is not a valid address. please check documentation”
- Check the sender address, whether it’s your account default in FlowRelay or an Override sender value, follows the
Name <[email protected]>format Mailgun expects - Look for stray characters or unescaped commas in the name portion; those are enough to fail Mailgun’s address parsing
- Confirm the address’s domain is the one you verified in Mailgun. Addresses on unverified or unrelated domains get rejected the same way