Reply by email
Answer a notification email as its recipient and have the reply posted to your app, as Mailgun Routes would.
Try it in the demo.
The situation: your app emails ticket updates from reply+<ticket>@reply.app.test, and people answer by email. In production, Mailgun receives the reply and posts it to your app. You want to test that handler locally.
You need: your app's inbound mail handler URL.
Steps
- In Settings > Email, add
reply.app.testto Inbound domains and save. - In Webhooks > Inbound routes, press Add route. Description "Ticket replies"; Match recipient with the pattern
reply\+(?P<ticket>.+)@reply.app.test. - The route starts with a Forward to URL action: set its target to your handler's URL. Then Add action > Stop, and press Add route.
- In your app, trigger a ticket notification. Open it in Mail, press Reply (
R), write "Thanks, that fixed it." above the quoted text, and press Send reply. - Your handler gets Mailgun's form post.
stripped-textholds only "Thanks, that fixed it.", and the ticket id is in the recipient.
In your code
A test that answers a ticket notification as its recipient; the inbound route posts the reply to your handler.
The examples call SendMock's REST API with each language's usual HTTP client and test framework. JavaScript, Go, Java, Rust, Ruby and C# use the small call helper shown under Test helper on their page in Connect your app.
# In your app: email the ticket update to [email protected]
email=$(sendmock email wait --to [email protected] --timeout 10s --json)
reply=$(sendmock email reply "$(jq -r '.id' <<<"$email")" --body 'Thanks, that fixed it.' --json)
jq -e '.direction == "inbound"' <<<"$reply" >/dev/nullWhat you should see
The reply in Mail with an Inbound badge, its Timeline saying "Forwarded by route Ticket replies to ...", and the request in Webhooks > Deliveries.
Try it in the demo
- Open Mail and click Your verification code.
- Press Reply, type
Got it, thanks.and press Send reply. - Press Open on the toast, then the Timeline tab: it shows "Forwarded by route Replies to no-reply to http://localhost:8000/webhooks/mail/inbound (200)".