...
We add a JSON schema to lib-auto-generated, org.sagebionetworks.repo.model.message.cloudmailin.Message, describing the CloudMailIn JSON format. A POST containing this message is authorized using 'Basic Authentication'. Also it takes a parameter, notificationUnsubscribeEndpoint, which is the Synapse Portal endpoint for one-click unsubscription. The message content is uploaded to an S3 with a MIME type application/x-cloudmailin-json.
...
json.
The message metadata (to, from, subject) is saved in Synapse as a MessageToUser object. We add a new field, notificationUnsubscribeEndpoint, to capture this metadata, used during message delivery (see below).
Message Delivery
The Synapse message system delivers messages via calls to Amazon Simple Email Service (SES) by asynchronous workers. The message metadata and S3 file are retrieved and, depending on whether the MIME type is text/plain or text/html, a plain or html message is constructed using the SES 'Formatted Email' API (http://docs.aws.amazon.com/ses/latest/DeveloperGuide/send-email-formatted.html). This system will be extended in two ways:
(1) For messages having MIME type application/json the CloudMailIn text, html, and attachments are assembled into a multipart message and sent via the SES 'raw' interface (http://docs.aws.amazon.com/ses/latest/DeveloperGuide/send-email-raw.html);
(2) For all messages, whether plain, html, or a combination, a one-click unsubscribe footer will be added.