Automatically Forward Emails Containing Tracking Numbers Using Regex


I’ve been using a great app called Delivery Status Touch for ages now. It allows you to add packages you’re expecting with their unique tracing number, then displays up-to-date information about them in the app.

Handy. But it gets better. If you sign up for their free syncing service on junecloud.com then not only can you also see your deliveries as a Dashboard widget on Mac OS X, but you can automatically add deliveries just by forwarding any email containing a tracking number.

I had some basic filters set up to automatically forward emails to Junecloud, but when I moved to Fastmail a few months ago I lost those filters. I finally got around to reinstating them, but in the process I discovered that Fastmail allows you to filter based on Regular Expressions.

These Regex filters should allow you to automatically forward any email containing a tracking number from the big three delivery services. (Note that if you also filter based on the subject containing “has shipped” you’ll get everything from Amazon.)

UPS

/\b(1Z ?[0-9A-Z]{3} ?[0-9A-Z]{3} ?[0-9A-Z]{2} ?[0-9A-Z]{4} ?[0-9A-Z]{3} ?[0-9A-Z]|[\dT]\d\d\d ?\d\d\d\d ?\d\d\d|\d{22})\b/

USPS

/^(7\d{19})|(\d{1}3\d{18})|(23\d{18})|((EA|EC|CP|RA)\d{9}US)|(82\d{8})$/

Fedex

/(\b96\d{20}\b)|(\b\d{15}\b)|(\b\d{12}\b)/

If you’re still languishing in the land of Google, all is not lost if you have your own domain email. With a Google Apps account you can use Regex as a content compliance filter. Probably easier just to switch to Fastmail.