smtp.send(config, message) Last updated: 30. May 2026

API only function

Send email by SMTP.

See also: Send mail from API function Sending forms by e-mail

Parameters

Name Type Description
config object | string

Configuration for SMTP server to send message through.
OR filepath to "SMTP configuration" file.

message object

Message object with SendTo, SendToCc, SendToBcc, ReplyTo, Subject, Message, IsHtml, Attachments and Headers.

Returns

True (boolean) or may throw a validation error.

Example

Code example (JS)

JS is normal JavaScript either running in the browser or on the Docly™ server.
// Use the default Docly SMTP structure:
let config = {
   "SendTo": "", // default value, used only if not specified in message object
   "SendToCc": "", // default value, used only if not specified in message object
   "SendToBcc": "", // default value, used only if not specified in message object
   "SendFrom": "no-reply@your-domain-here.com", // Required, always used
   "SmtpServer": "your-smtp-server-here",
   "SmtpPort": 587,
   "SmtpUser": "login user",
   "SmtpPass": "login password",
   "SmtpSsl": true
};

// Or load it from a file:
// let config = docly.getFile("#/My Smtp");

// Use the default Docly Message structure:
let message = {
   "SendTo": "test@my-email.com",
   "SendToCc": "",
   "SendToBcc": "",
   "ReplyTo" : "", // Optional
   "Subject" : "Subject for message",
   "Message" : "Hello there",
   "IsHtml" : false,
   "Attachments" : [],
   "Headers": { // Optional, add any desired headers for the email
       "In-Reply-To": "....",
        // etc
   }
};


let filedata = []; // TODO: array of bytes or base64 encoded string

// Add one or more files to message
message.Attachments.push({ "Filename" : "Test file.pdf", "Data" : filedata });

// Send the message through server
smtp.send(config, message);