Send Emails
Totalum allows you to send emails programmatically using the Totalum API or SDK. The email service supports custom HTML content, attachments, CC, BCC, and reply-to options.
📚 Setup Required: For installation and usage of the Totalum SDK or API, see the Installation Guide.
Send a basic email
const emailPayload = {
to: ['[email protected]'],
subject: 'Your email subject',
html: '<h1>Hello</h1><p>This is the email content in HTML</p>',
};
const result = await totalumClient.email.sendEmail(emailPayload);
Send an email with all options
const emailPayload = {
to: ['[email protected]', '[email protected]'], // array of recipients
subject: 'Your email subject',
html: '<h1>Hello</h1><p>This is the email content in HTML</p>',
fromName: 'Your Company Name', // optional: custom sender name
cc: ['[email protected]'], // optional: carbon copy recipients
bcc: ['[email protected]'], // optional: blind carbon copy recipients
replyTo: '[email protected]', // optional: reply-to address
attachments: [ // optional: array of attachments (max 10, each up to 15MB)
{
filename: 'document.pdf',
url: 'https://example.com/path/to/document.pdf',
contentType: 'application/pdf' // optional
},
{
filename: 'image.png',
url: 'https://example.com/path/to/image.png',
contentType: 'image/png' // optional
}
]
};
const result = await totalumClient.email.sendEmail(emailPayload);
Send an email with files from Totalum storage
If you have uploaded files to Totalum and want to send them as attachments, you need to get their download URLs first:
// First, get the download URL of the file uploaded to Totalum
const fileNameId = 'your_file_name.pdf'; // the file name ID from Totalum
const fileUrlResult = await totalumClient.files.getDownloadUrl(fileNameId);
const fileUrl = fileUrlResult.data;
// Then, send the email with the attachment
const emailPayload = {
to: ['[email protected]'],
subject: 'Email with attachment from Totalum',
html: '<h1>Hello</h1><p>Please find the attached document</p>',
attachments: [
{
filename: 'document.pdf',
url: fileUrl,
contentType: 'application/pdf'
}
]
};
const result = await totalumClient.email.sendEmail(emailPayload);
Important notes
- Maximum attachments: 10 attachments per email
- Maximum size per attachment: 15MB
- Attachment URLs: All attachments must be provided as valid HTTP/HTTPS URLs
- HTML content: You can use full HTML and CSS in the email body
- Recipients: The
tofield must be an array of email addresses