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:
| Provider | Free Tier | Pricing |
|---|---|---|
| Cloudflare R2 | 10GB storage, unlimited egress | $0.015/GB storage |
| DigitalOcean Spaces | 250GB for $5/mo | $5/month flat |
| AWS S3 | 5GB for 12 months | ~$0.023/GB |
| Backblaze B2 | 10GB free | $0.005/GB |
Option 1: Cloudflare R2 (Recommended)
R2 has no egress fees — you only pay for storage.
Step 1: Create a Bucket
- Log into Cloudflare Dashboard
- Go to R2 Object Storage
- Click Create bucket
- Name it
maillayeror similar - Click Create bucket
Step 2: Set Up Public Access
- In your bucket, go to Settings
- Under Public access, click Allow Access
- Add a custom domain or use the R2.dev subdomain
Step 3: Create API Token
- Go to R2 → Manage R2 API Tokens
- Click Create API token
- Select Object Read & Write permissions
- 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
- Log into DigitalOcean
- Go to Spaces Object Storage
- Click Create a Space
- Choose a region close to your users
- Name it
maillayer-cdn - Select Public access (for email images)
- Click Create Space
Step 2: Generate API Keys
- Go to API in the left sidebar
- Under Spaces Keys, click Generate New Key
- Name it
maillayer - 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
- Go to S3 Console
- Click Create bucket
- Name it
maillayer-images - Uncheck Block all public access (required for email images)
- 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:
- Restart your Maillayer instance
- Go to Campaigns → create a new campaign
- Add an image using the editor
- 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_URLis 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
