Docs
BlogHomeStart building

Send Emails

Deliver HTML emails with attachments, CC, BCC, and reply-to straight from Totalum.


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

javascript
const emailPayload = {
    to: ['recipient@example.com'],
    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

javascript
const emailPayload = {
    to: ['recipient1@example.com', 'recipient2@example.com'], // 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: ['cc@example.com'], // optional: carbon copy recipients
    bcc: ['bcc@example.com'], // optional: blind carbon copy recipients
    replyTo: 'reply@example.com', // 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:

javascript
// 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: ['recipient@example.com'],
    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