Smart Application Messaging: The Email Reflector
Patrick Reagan, Former Development Director
- Aligns with their current skill sets when it comes to messaging (e.g., using Outlook as the preferred email application).
- Allows them to deliver customized messages to every subset of their user base.
- Provides dynamic capabilities so that each time a new user is added, he or she will start receiving the appropriate messages.
- Instead of easily firing off an email from their address book, clients are now forced to log into the web application, run a report, and grab the contact list – not a simple proposition.
- If the list of emails is large enough, the risk of exceeding the maximum number of recipients increases – not something we want our clients to have to suffer through.
- Since this is a manual process, any human error introduces the possiblity of exposing our distribution list, compromising the privacy of our user base.
- Any advanced features (e.g., attachments, alternate content) that the client is familiar with in their existing email application will have to be custom-built into our new web-based system.
- Though not necessarily difficult (depending on the implementation), the client now has to re-learn how to send a message from the new web application.
- Set up the MTA to push raw email content to a script.
- Gather a list of email addresses.
- Redirect the raw message to the list of recipients.
|/path/to/demo/reflector.phpThis handles the messages as they come in; but, we still need to decide who will ultimately receive the message. Step #2: Gather the Email Addresses This is pretty simple: we just need to get a list of addresses based on certain reporting criteria. Once we have this list, we can send the original message on its way, stripping the original "To" address and any unnecessary "Received" headers before we send. Step #3: Send the Message Using the provided EmailReflector class, we can push off all the heavy-lifting to it with just a few lines of code:
$reflector = new EmailReflector('smtp-host'); $reflector->setInputSource('php://stdin'); $reflector->redirect($recipientList);The message is now Bcc'd to the specified list of recipients with all the original contents (including attachments) in place. Enhancements Because this is still "proof-of-concept" code, there are some issues that still need to be addressed:
- Security - If someone can guess the target email address for the reflector, he or she has the ability to spam your site's users. By making the target email harder to guess (good) or having the sender provide a security token (better), we can minimize this risk.
- Batching - As a site's user base grows, the number of emails that will be sent through this sytem increases. By providing some basic batching features, we can handle a larger volume.
- Catch-all addresses - A reporting feature that I see as useful would give users the ability to generate a report and save it with an associated email address. Any time a message is sent to this address, it will regenerate the report and send the email. Setting up a catch-all email address for a subdomain would make this possible.