Overview
SendLayer allows you to send emails with file attachments. This guide shows you how to send emails with attachments using the SendLayer API, with examples for popular programming languages.Prerequisites
Sending Emails with Attachments
You can attach files to your emails by including anattachments
array in your email parameters. The SendLayer SDKs handle file encoding automatically, so you only need to provide the file path and type.
The maximum file size per email is 10 MB, including both the email content and all attachments combined.
Replace
<apiKey>
with your actual SendLayer API key in the request header. The Content
field in the cURL example should contain the actual base64-encoded file content.Multiple Attachments
You can attach multiple files to a single email by adding more objects to theattachments
array.
Local and Remote File Attachments
SendLayer SDKs support both local and remote file attachments. For local files, you’ll need to provide the path to the file you intend to attach. For remote files, simply provide the URL.Supported File Types
SendLayer supports a wide range of file types for attachments. Here are some common MIME types:- Documents:
application/pdf
,application/msword
,application/vnd.openxmlformats-officedocument.wordprocessingml.document
- Spreadsheets:
application/vnd.ms-excel
,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
- Images:
image/jpeg
,image/png
,image/gif
- Text Files:
text/plain
,text/csv
- Archives:
application/zip
,application/x-rar-compressed
See our Send Email guide for basic email sending instructions.
FAQ
What is the maximum file size for attachments?
What is the maximum file size for attachments?
The maximum file size per email is 10 MB, which includes both the email content and all attachments combined. If you need to send larger files, consider using cloud storage services and including download links in your emails.
How many files can I attach to a single email?
How many files can I attach to a single email?
You can attach multiple files to a single email, but the total size of all attachments plus the email content must not exceed 10 MB. There is no specific limit on the number of files, only the total size limit.
What file formats are supported?
What file formats are supported?
SendLayer supports most common file formats including PDFs, Word documents, Excel spreadsheets, images (JPEG, PNG, GIF), text files, and compressed archives. The file type should be specified using the appropriate MIME type.
How do I attach files with the SDK?
How do I attach files with the SDK?
The SendLayer SDKs handle file encoding automatically. Simply provide the file path (for local files) or URL (for remote files) along with the MIME type. The SDK will read and encode the file for you.
Can I attach files when sending to multiple recipients?
Can I attach files when sending to multiple recipients?
Yes, you can attach files when sending to multiple recipients. The same attachment will be sent to all recipients in the email. See our Send Email to Multiple Recipients guide for more details.
What should I do if my attachment is too large?
What should I do if my attachment is too large?
If your attachment exceeds the 10 MB limit, consider compressing the file, using a cloud storage service and including a download link, or splitting the content into multiple emails with smaller attachments.