Skip to content


$.net.SMTPConnection class for sending $.net.Mail objects via SMTP connection.


Sample Usage


Requires a running mail server. If mailConfig is not set the api defaults to a local mail server. For more information please take a look here.

var net = $.net

// Create email from JS Object.
var mail = new net.Mail({
   sender: {address: ""},
   to: [{ name: "John Doe", address: ""}, {name: "Jane Doe", address: ""}],
   cc: [{address: ""}, {address: ""}],
   bcc: [{ name: "Jonnie Doe", address: ""}],
   subject: "subject",
   subjectEncoding: "UTF-8",
   parts: [ new net.Mail.Part({
       type: net.Mail.Part.TYPE_TEXT,
       text: "The body of the mail.",
       contentType: "text/plain",
       encoding: "UTF-8",

// Set mail server configurations.
let mailConfig = {
    "mail.user": "<your-user>",
    "mail.password": "<your-password>",
    "mail.transport.protocol": "smtps",
    "": "<your-mail-provider-host>",
    "mail.smtps.port": "465",
    "mail.smtps.auth": "true"

var smtp = new net.SMTPConnection(mailConfig);
let returnValue = smtp.send(mail);



new $.net.SMTPConnection(mailConfig)


Parameter Name Description Required Type
mailConfig JS object containing mail server configuration properties. optional object

mailConfig Properties

Property Description Type
mail.user The mailbox user string
mail.password The mailbox password string
mail.transport.protocol (optional) The mail transport protocol, default is smtps string The mail SMPTPS host string
mail.smtps.port The mail SMPTPS port number as string
mail.smtps.auth Enable/Disable mail SMPTPS authentication boolean as string The mail SMPTP host string
mail.smtp.port The mail SMPTP port number as string
mail.smtp.auth Enable/Disable mail SMPTP authentication boolean as string

Addition mail client options can be found here: - SMTP/SMTPS - IMAP - POP3


Function Description Returns
close() Mocked. The SMTP Connection is now automatically closed after calling the send method. void
isClosed() Mocked. The SMTP Connection is always closed. boolean
send(Mail) Accepts and sends the net.Mail class. void