• What's new

Weekly Product Update: Easy Testing For Routes Webhooks

Mailgun Team
5 min read

Last week we released a much-requested email tracking feature: domain-level webhooks. Continuing on that theme, this week we’ve released another webhook-related feature: easy testing for Routes webhooks. Now you can test your Routes webhook endpoints by POSTing a sample message to your app directly from your Mailgun control panel. We’ll be rolling out a similar Test feature for Tracking webhooks in the coming weeks so stay tuned for that.

Testing your Routes webhooks

We’d tried to make testing your Routes webhooks as simple as possible. All you need to do is enter a URL where you want to receive an HTTP POST and we’ll POST a sample message with values for all available parameters. This way you can test your webhook handler and make sure everything is working properly prior to sending real email traffic. As always, you can also test how your Routes match against certain Filter Expressions you’ve created.

A sample Flask app for accepting webhooks

We’ve posted this code before, and we’ll post it again here because its helpful. If you’re using webhooks to parse incoming messages, you need a way to process the incoming data. Here is a little Flask app that you can use to get started and customize for your specific use case.

from flask import Flask from flask import request app = Flask(__name__) @app.route('/mailgun-tracking', methods=['GET', 'POST']) def tracking(): # access some of the email parsed values: request.form['recipient'] request.form['from'] request.form['subject'] # extended parameters request.form['Message-Id'] request.form['message-headers'] request.form['timestamp'] request.form['body-plain'] request.form['stripped-html'] request.form['stripped-text'] request.form['stripped-signature'] return "Ok" if __name__ == '__main__': app.run(host='50.56.174.200', port=100, debug=True)

Till next week.

Happy sending!

The Mailgunners

sign up

It's easy to get started. And it's free.

What will you accomplish with 10,000 free emails and a 100 free validations every month?

Sign Up For Free

Last updated on August 29, 2019

  • Related posts
  • Recent posts
  • Top posts
View all

Always be in the know and grab free email resources!

No spam, ever. Only musings and writings from the Mailgun team.

Mailgun is committed to protecting your privacy. Please read ourPrivacy Policybefore providing us with your details.

sign up

It's easy to get started. And it's free.

What will you accomplish with 10,000 free emails and a 100 free validations every month?
Sign up for Free