📖
Rulecube documentation
v2.4
v2.4
  • Overview
  • Quick Start
  • Tutorial
    • Getting started
    • Create and Run Your First Ruleset
    • Use Constants and Methods
    • Create and Call Functions
    • Adding Testcases
    • Using Lookup Tables
    • Using Entities
    • Using Forms
  • How-to Guides
    • Logging in and Authorization
      • Activate Your Account From an Invitation
      • Log in to Rulecube
      • Change Your Password
      • Recover Your Password
      • Two-factor authentication (2FA)
      • Invite Other Users to Rulecube
      • Edit a User's Role
      • Delete a User
    • Ruleset Development
      • Create a Ruleset
      • Set the Input for a Ruleset
      • Create a Rule
      • Generate Alerts
      • Try out a Ruleset
      • Call a Ruleset from Your Software
      • Entities
        • Create an Entity
        • Drag and Drop a JSON Schema or XSD to create entities
        • Entity instantiation
        • Persisted Entities
      • Constants
        • Constant Tables
      • Functions
      • Built-in Functions
      • Create and Run a Testcase
      • Delete a Ruleset or Components
      • Debugging your Ruleset
    • Create a Workflow
      • Workflow step types
      • Working with documents in a workflow
    • Work with (Environment) Variables
    • Call a Ruleset via Its API From Postman
    • Creating input from JSON Schema
    • Use a Ruleset from Your Software
    • Ruleset Productivity Tips
    • Create an Ockto workflow
    • Alert aggregation
    • Forms
      • Introduction and overview
      • Create a Data table
  • Language Reference
    • Global
    • Array
    • Compression
    • Crypto
    • Date
    • Encryption (deprecated)
    • Finance
    • Http
    • Mail
    • MongoDB
    • Ockto
    • PDF
    • SQL
    • Statistics
    • System
    • UserStore
    • Workflow
Powered by GitBook
On this page
  1. Language Reference

Mail

Collection of e-mail functions.

Methods

send

send(smtpSettings: { host: string, port?: number, auth?: { user: string, pass: string }, secure?: boolean }, mailOptions: { from: string, to: string | string[], cc?: string | string[], bcc?: string | string[], subject: string, text?: string, html?: string, attachments?: { filename: string, content?: string, path?: string, contentType?: string, encoding?: string, cid?: string }[] })

Send an e-mail to one or more recipients.

Parameters

smtpSettings { host: string, port?: number, auth?: { user: string, pass: string }, secure?: boolean }

The SMTP connection settings.

mailOptions { from: string, to: string | string[], cc?: string | string[], bcc?: string | string[], subject: string, text?: string, html?: string, attachments?: { filename: string, content?: string, path?: string, contentType?: string, encoding?: string, cid?: string }[] }

The mail options. Includes the from, to, subject, text and html properties.

Return type

{ accepted: string[], rejected: string[], envelopeTime: number, messageTime: number, messageSize: number, response: string, envelope: { from: string, to: string[] } }

Examples

Mail.send({ 
  host: 'smtp.example.com',
  port: 587,
  auth: {
    user: 'admin',
    pass: 'rosebud'
  }
}, 
{
  from: '"Sender Name" <sender@example.com>',
  to: 'someone.else@example.com',
  subject: 'Hello!',
  text: 'This is the plain text body (optional)!',
  html: 'This is the <b>HTML</b> body!'
})

// You can also send to multiple recipients and even add attachments:
Mail.send(smtpSettings, // For brevity, assume this is already defined
{
  from: '"Sender Name" <sender@example.com>',
  to: ['someone.else@example.com', 'another.one@example.com'],
  cc: ['cc1@example.com', 'cc2@example.com'],
  bcc: ['bcc1@xample.com', 'bcc2@example.com],
  subject: 'Hello!',
  html: 'This is the <b>HTML</b> body with embedded image: <img src="cid:Logo"/>'
  attachments: [
    { filename: 'text1.txt', content: 'hello world!' },
    { filename: 'text2.txt', content: 'goodbye world!' },
    { filename: 'logo.png', cid: 'Logo', path: 'data:image/png;base64,[Base64 encoded image here]' },
  ]
})
PreviousHttpNextMongoDB

Last updated 1 month ago