Working with Large Attachments

In order to save overhead on your server CloudMailin can transfer your attachments directly to Amazon's S3.

Large Attachments and Timeouts

When a large attachment, or multiple attachments, are included within an email message the amount of data sent to the target website can become quite large. This can in turn lead to considerable transfer and processing time on your server and can often result in timeouts or unreachable errors as the server cannot cope with receiving that amount of data. In addition, this overhead can prevent other requests from reaching the server.

CloudMailin has the ability to extract the attachments from your email and deliver them to Amazons S3. This means that your server only receives the data that it needs to, and we instead pass the URL of the files that were extracted from the email.

Sending Email Attachments to Amazon S3

It is possible to configure CloudMailin to stream message attachments to Amazons S3 as an email is received. This can help reduce the overhead on the end server and allow you to easily save away the attachments sent by your customers. In order to set up S3 attachments:

  1. Log into your address dashboard and choose the address you wish to manage.
  2. Select add attachment store.
  3. Enter your amazon S3 bucket name and an optional path to place before each file. In the format bucketname/pathprefix.
  4. Select the permission that you wish for files to be created with bucket-owner-full-control or public-read.
  5. Make sure you give write access for CloudMailin to your Amazon S3 bucket from the Amazon AWS dashboard.

In order for this to work you must give write access to your bucket to the following Amazon Canonical ID:

AWS Canonical ID: 83fec836f8a832fae9c46e100739b635be3b3636d14887e1c7616e2dba1a88c0

Once this is configured correctly you will see an additional attachments parameter being passed with the content type, url and original file name of your attachments. For more details about the attachment format see the documentation on the HTTP Post Formats.

Giving CloudMailin permission to write to your S3 Bucket.

There are several ways that you can grant permission for CloudMailin to create files in your S3 Bucket. The simplest is to use the AWS website.

  1. Head to
  2. Sign in to the management console
  3. Click on the S3 Tab, then select your bucket
  4. Click the properties button
  5. You should be presented new box with the word permissions on it
  6. In the grantee field from above paste the CloudMailin Canonical ID, choose upload/delete and then save

You should now have granted CloudMailin permission to add files to your S3 bucket.

Adding the Canonical ID

CloudMailin will upload attachments using a random filename generated by our system. This is because we don't wish to require read access only write access to a bucket and we therefore cannot check if a file already exists. Although it is unlikely it is theoretically possible that we could generate the same filename twice. If this is a concern you should move the files once you receive the url from our servers.