I have a Brother MFC-9970CDW, a wonderful multi-function color laser printer (aka a MFP or MFC). (Okay, so it’s hardware is a little cheap and the software was clearly designed by and for engineers, but hey… it gets the job done.) One of the nice things about the Brother is that it features a high-capacity sheet-fed duplex scanner that emails PDF documents to the addressee of your choice. A set of “one touch” buttons on the control panel make it easy to send your documents to one of twenty email addresses.
Evernote allows you to email the documents of your choice to a unique email address associated with your account. You can specify the destination notebook and tags in the subject of the email, using the format “My note title @notebook #tag”.
Wouldn’t it be great to be able to have several buttons on the control panel, each corresponding to different notebooks and tags? For instance, it would be nice to scan something directly to my @Chris notebook with a tag such as #Receipts, #Taxes, #Bills, etc. You get the idea.
There’s only one problem: The Brother allows you to specify the email subject, but only globally. So, that’s not going to work. In fact, the only thing you can do on a message-by-message basis is specify the destination email address and the file type. So, how can we specify the notebook and tags with our one-touch buttons?
Easy. Add an intermediary script that receives the message, looks at a crafted “to” address, rewrites the message, and forwards it on to Evernote.
In short: Email to Chris+Receipts@en.chrisgagne.com -> perl script changes subject to “Scanned Item @Chris #Receipts” and removes the text of the body -> perl script forwards the email to email@example.com.
Why am I using a sub-domain? It’s the easiest way to get flexibility on the “to” address without mucking with the rest of my @chrisgagne.com email.
So here’s a (really kludgy) script I wrote.
# ©2012 Chris Gagné
# This script is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
# Please share your improvements here: http://chrisgagne.com/942/scanning-from-a-brother-mfc-to-evernote/
# To use this script:
# 1. Configure your Evernote email address on line 46.
# 2. Upload it to your server and give it the necessary permissions for execution.
# 3. Create a subdomain (such as en.yourdomain.com) and pipe all of the email going to this subdomain to this script.
# 4. Configure your printer to send emails firstname.lastname@example.org where is the desired notebook name and is the desired tag.
# There's a number of limitations with this script, including:
# 1. It only allows for one tag. This isn't a hard problem to solve but I'm lazy and I only need one tag.
# 2. Any special characters you use in your notebook and tag names must be valid characters in email addresses.
# 3. This script doesn't remove all non-essential parts of these mail messages, but most MFPs emails are sparse anyway.
# 4. It doesn't any validation on the sender. The odds of a spammer guessing your subdomain are pretty low, though.
use Errno 'EEXIST';
use POSIX 'strftime';
use Mail::Message ();
use MIME::Types ();
# Read the message from STDIN
my $from_line = <>; # usually added by the local MTA
my $msg = Mail::Message->read(\*STDIN);
# Grab the list of "to" addresses on the email
my @to_addresses = $msg->to;
# Grab the user part of the first "to" address
my $to_address = $to_addresses->user;
# Split the user name part of the "to" address into a notebook name and tag name (format is "+@en.yourdomain.com")
(my $notebook, my $tag) = split(/\+/,$to_address,2);
# Construct a new, blank message body
my $newBody = Mail::Message::Body->new(data => " ");
# Compose and forward a new message from the new message (sans deleted parts), new blank message body
This should work for any Brother MFC that supports scanning to email addresses. For those who are searching for this solution, here’s a list of printers that Brother claims supports the “Scan to email server” function as of 6/1/2012. Your milage may vary.