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.
What happens if you are not programming in javascript?β
If you are not programming in javascript, you can use the api directly, see TOTALUM API DOCUMENTATION
If you are programming in javascript, you can use the totalumSdkβ
Note: If you use totalumSdk inside a totalum plugin, you don't need to authenticate, you can start using totalum sdk functions like this: modules.totalumSdk.email.sendEmail(emailPayload); etc...
If you have questions about how to install and use TotalumSdk, check the documentation: Totalum SDK Installation, and Using the SDK
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
to
field must be an array of email addresses