Skip to main content

SMTP - Simple Mail Transfer Protocol

SMTP (Simple Mail Transfer Protocol) is a protocol used for sending email messages between servers. OsmoX uses Nodemailer, a popular Node.js library, to send emails using SMTP transport.

Configuration

Database Setup

Create a new entry in the notify_providers table with the following settings:
FieldValue
channel_type1 (SMTP)
is_enabled1

Configuration Fields

SMTP_HOST
string
required
SMTP server hostname
SMTP_PORT
number
required
Port number for SMTP (587 for TLS, 465 for SSL)
SMTP_USERNAME
string
required
Your SMTP username for authentication
SMTP_PASSWORD
string
required
Your SMTP password for authentication
Example Configuration:
{
  "SMTP_HOST": "smtp.example.com",
  "SMTP_PORT": 587,
  "SMTP_USERNAME": "your-smtp-username",
  "SMTP_PASSWORD": "your-smtp-password"
}

Request Format

Sample Request Body

{
  "providerId": 1,
  "data": {
    "from": "sender@example.com",
    "to": "recipient@example.com",
    "cc": "cc@example.com",
    "bcc": "bcc@example.com",
    "subject": "Test subject",
    "text": "This is a test notification",
    "html": "<b>This is a test notification</b>",
    "attachments": [
      {
        "filename": "names.txt",
        "content": "John Doe\nJane Doe"
      }
    ],
    "headers": {
      "X-Custom-Header": "Custom Value"
    }
  }
}

Request Fields

from
string
required
Sender’s email address
to
string | string[]
required
Recipient’s email address. Can be a single address or comma-separated list
cc
string | string[]
CC email addresses
bcc
string | string[]
BCC email addresses
subject
string
required
Email subject line
text
string
Plain text version of the email
html
string
HTML version of the email
attachments
array
Array of attachment objects with filename and content
headers
object
Additional custom headers to include in the email
Currently, attachments only support text content as shown in the example.

Dependencies

PackageVersionDescription
nodemailer^6.10.0Email sending library for Node.js

Reference