Product

Agape charity finds easy way to forward email for volunteers worldwide

This post was written by Huey Ly. Huey is a software developer living and working in Xi’an China, home of the Terracotta warriors. He is the co-founder & lead developer for whyyu.com, a language learning app to teach English to Chinese children. In his spare time, he helps charitable organizations take advantage of technology to further their mission. He’s also a very brave dancer.

PUBLISHED ON

PUBLISHED ON

This post was written by Huey Ly. Huey is a software developer living and working in Xi’an China, home of the Terracotta warriors. He is the co-founder & lead developer for whyyu.com, a language learning app to teach English to Chinese children. In his spare time, he helps charitable organizations take advantage of technology to further their mission. He’s also a very brave dancer.

I volunteer part time at the Agape Community Care Association (www.agape.org), an NGO that helps orphans and other disadvantaged people in the Shaanxi province of China. Agape has volunteers and staff from all over the world, and most of their email accounts are hosted at free providers such as Gmail, Hotmail, or Yahoo. Agape wanted each volunteer to have their own @agape.org.cn email address to give the organization more legitimacy locally and internationally, but migrating and consolidating all the mailboxes of such a diverse group proved to be quite a headache. Additionally, the added cost of all the extra mailboxes would put a dent in their already minuscule funding (they only keep 10% of donations for administrative purposes, the rest goes directly to the orphanages and health clinics). What can they do?

Email forwarding using Routes

Routes allow you to set up a series of rules on how to handle incoming messages, like those sent to @agape.org.cn . Specifically:

  • Which messages to act on (e.g. messages from a particular person or with a particular subject or even all messages)

  • What you want to do with those messages (e.g. forward it to another email address or POST it to your app)

For Agape, I wanted to match on anything sent to a user with an @agape.org.cn address and forward the email to another address, but Mailgun also allows you elect to post the message to your app: Mailgun will either send you the entire unparsed MIME message (if that’s your thing) or parse it for you and POST the parsed parameters. In both cases, they’ll transcode the message to UTF-8 which is a really nice bonus.

Setting up 100s of Routes at once using the API

Using Mailgun Routes, Agape was able to forward all emails sent to [user]@agape.org.cn addresses to everyone’s personal email accounts. No migrations needed! What’s more, the API system allowed us to write a script that quickly imports hundreds of routes quickly and easily, using a .csv file. Let me show you what I mean.

1. First, we create a .csv file of source and forwarding address separated by commas, one pair per line, like so:

example1@agape.org.cn, somemailbox@hotmail.com example2@agape.orgcn, someotherbox@gmail.com

2. Next, we create a function that calls the Mailgun API to “add a new route”.

3. Then we create a function that parses the .csv file to an array, iterate through it, and call the API function to add each route:

4. Then simply make sure the script and .csv file are in the same directory (or change $filepath variable to match your .csv file’s filepath) and run the script: run_importer();

It’s really quite simple. Using the Mailgun Routes API, we were able to quickly add hundreds of forwarding addresses so that Agape employees and volunteers worldwide can easily access their Agape email. Thanks Mailgun!

Sign Up

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

See what you can accomplish with the world’s best email delivery platform.

Related readings

How Node.js app Cloud Monitoring uses the Mailgun API to automate email workflow

This post is written by Dan Di Spaltro, Director of Product for Rackspace Cloud Monitoring. Cloud Monitoring lets you monitor any...

Read more

How Kanban2go fulfills Zawinski’s Law

I don’t know if that is true, but kanban2go took a step in that direction recently with the...

Read more

Using Mailgun with Capistrano recipes

Mailgun was created to be an antidote for email development pain. So, it always thrills us when developers take our platform a step...

Read more

Popular posts

Email inbox.

Build Laravel 10 email authentication with Mailgun and Digital Ocean

When it was first released, Laravel version 5.7 added a new capability to verify user’s emails. If you’ve ever run php artisan make:auth within a Laravel app you’ll know the...

Read more

Mailgun statistics.

Sending email using the Mailgun PHP API

It’s been a while since the Mailgun PHP SDK came around, and we’ve seen lots of changes: new functionalities, new integrations built on top, new API endpoints…yet the core of PHP...

Read more

Statistics on deliverability.

Here’s everything you need to know about DNS blocklists

The word “blocklist” can almost seem like something out of a movie – a little dramatic, silly, and a little unreal. Unfortunately, in the real world, blocklists are definitely something you...

Read more

See what you can accomplish with the world's best email delivery platform. It's easy to get started.Let's get sending
CTA icon