When you add images to your email campaigns, they need to be hosted somewhere accessible. Cloud storage ensures fast, reliable image delivery worldwide.

Why Cloud Storage?

  • Faster emails — Images load from CDN edge servers
  • Reliability — No dependency on your Maillayer server
  • Scalability — Handle thousands of image requests
  • Persistence — Images stay available even if you redeploy

Supported Providers

Maillayer works with any S3-compatible storage:

ProviderFree TierPricing
Cloudflare R210GB storage, unlimited egress$0.015/GB storage
DigitalOcean Spaces250GB for $5/mo$5/month flat
AWS S35GB for 12 months~$0.023/GB
Backblaze B210GB free$0.005/GB

Option 1: Cloudflare R2 (Recommended)

R2 has no egress fees — you only pay for storage.

Step 1: Create a Bucket

  1. Log into Cloudflare Dashboard
  2. Go to R2 Object Storage
  3. Click Create bucket
  4. Name it maillayer or similar
  5. Click Create bucket

Step 2: Set Up Public Access

  1. In your bucket, go to Settings
  2. Under Public access, click Allow Access
  3. Add a custom domain or use the R2.dev subdomain

Step 3: Create API Token

  1. Go to R2Manage R2 API Tokens
  2. Click Create API token
  3. Select Object Read & Write permissions
  4. Copy the Access Key ID and Secret Access Key

Step 4: Add Environment Variables

Add these to your deployment:

STORAGE_PROVIDER=cloudflare
STORAGE_ENDPOINT=https://<account-id>.r2.cloudflarestorage.com
STORAGE_ACCESS_KEY=your-access-key-id
STORAGE_SECRET_KEY=your-secret-access-key
STORAGE_BUCKET=maillayer
STORAGE_PUBLIC_URL=https://your-custom-domain.com

Replace <account-id> with your Cloudflare account ID (found in the R2 dashboard).


Option 2: DigitalOcean Spaces

Spaces includes a built-in CDN with simple pricing. New accounts get $200 free credit for 60 days.

Step 1: Create a Space

  1. Log into DigitalOcean
  2. Go to Spaces Object Storage
  3. Click Create a Space
  4. Choose a region close to your users
  5. Name it maillayer-cdn
  6. Select Public access (for email images)
  7. Click Create Space

Step 2: Generate API Keys

  1. Go to API in the left sidebar
  2. Under Spaces Keys, click Generate New Key
  3. Name it maillayer
  4. Copy both the Key and Secret

Step 3: Add Environment Variables

STORAGE_PROVIDER=digitalocean
STORAGE_ENDPOINT=https://sgp1.digitaloceanspaces.com
STORAGE_ACCESS_KEY=your-spaces-key
STORAGE_SECRET_KEY=your-spaces-secret
STORAGE_BUCKET=maillayer-cdn
STORAGE_PUBLIC_URL=https://maillayer-cdn.sgp1.digitaloceanspaces.com

Replace sgp1 with your Space's region (e.g., nyc3, ams3, sfo3).


Option 3: AWS S3

Use S3 if you're already on AWS.

Step 1: Create a Bucket

  1. Go to S3 Console
  2. Click Create bucket
  3. Name it maillayer-images
  4. Uncheck Block all public access (required for email images)
  5. Click Create bucket

Step 2: Set Bucket Policy

Add this policy to allow public read access:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Principal": "*",
      "Action": "s3:GetObject",
      "Resource": "arn:aws:s3:::maillayer-images/*"
    }
  ]
}

Step 3: Add Environment Variables

STORAGE_PROVIDER=s3
STORAGE_ENDPOINT=https://s3.us-east-1.amazonaws.com
STORAGE_ACCESS_KEY=your-aws-access-key
STORAGE_SECRET_KEY=your-aws-secret-key
STORAGE_BUCKET=maillayer-images
STORAGE_PUBLIC_URL=https://maillayer-images.s3.us-east-1.amazonaws.com

Testing Your Setup

After adding the environment variables:

  1. Restart your Maillayer instance
  2. Go to Campaigns → create a new campaign
  3. Add an image using the editor
  4. Check that the image URL points to your storage provider

Troubleshooting

Images not uploading

  • Verify your access key and secret are correct
  • Check the endpoint URL matches your provider/region

Images not displaying in emails

  • Ensure your bucket has public read access
  • Verify the STORAGE_PUBLIC_URL is accessible

CORS errors in editor

  • Add CORS policy to your bucket allowing your Maillayer domain

Next: Email Campaigns — Create and send email campaigns

Previous: Production Access — Request AWS SES production access