---
title: Mail
project: Total.js V4
version: 0.0.99
section: reference
language: en
license: MIT
url: https://totaljs.es/docs/total-js-v4/0-0-99/reference/mail/
updated: 2026-11-16T15:41:05.817Z
---

# Mail

> Global mail functions, the mail configuration, the Mail module and the message object.

`MAIL()`, `HTMLMAIL()`, `LOGMAIL()` and `controller.mail()` send email with the SMTP server from the configuration; the `Mail` module creates and sends messages to any server. In this reference `message` is a message returned by these functions or by `Mail.create()`. The guide [Sending email](../../guides/mail/) explains how to use them with examples; this page is the exact reference.

## API

### MAIL(address, subject, view, [model], [language], [callback])

Type: `method`

Renders a view and sends it as an HTML email.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `address` | `String|Array` | yes |  | One email address or an array of addresses; each one becomes a `To` recipient. |
| `subject` | `String` | yes |  | The subject. |
| `view` | `String` | yes |  | The name of a view in `views/`, for example `mails/welcome`. |
| `model` | `Object` | no |  | The model of the view. |
| `language` | `String` | no |  | A language for the subject and the view. |
| `callback` | `Function` | no |  | Called with `function(err, message)` when the message has been written to the server, or with the reply line when the server rejects it. |

Returns: `MailMessage` The message, before it is sent.

The view is rendered without a layout; the model is available as `model`. With `language`, the subject is translated (a subject with `@(...)` is translated by its parts) and the view is rendered in this language. A view name that starts with `=theme/` is taken from this theme. The sender, reply-to and copies come from the configuration. The message is sent on the next tick, so you can still change it. `callback` can also be the fifth argument and `language` the sixth.

Example: A welcome email
```js
MAIL('peter@example.com', 'Welcome', 'mails/welcome', { name: 'Peter' }, function(err) {
	err && console.log('Not sent', err);
});
```

Example: Translated, with an attachment
```js
MAIL(user.email, '@(Your invoice)', 'mails/invoice', invoice, user.language).attachment(filename, 'invoice.pdf');
```

### HTMLMAIL(address, subject, body, [language], [callback])

Type: `method`

Sends an HTML string as an email.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `address` | `String|Array` | yes |  | One email address or an array of addresses; each one becomes a `To` recipient. |
| `subject` | `String` | yes |  | The subject. |
| `body` | `String` | yes |  | The HTML of the message. |
| `language` | `String` | no |  | A language for the subject and the body. |
| `callback` | `Function` | no |  | Called with `function(err, message)` when the message has been written to the server, or with the reply line when the server rejects it. |

Returns: `MailMessage` The message, before it is sent.

A body without a `<body>` element is wrapped in a full HTML document with the subject as the title and a `<body>` with normalized CSS (no margin, Arial 14px). With `language`, the subject is translated and the `@(...)` texts of the body are translated too. `callback` can also be the fourth argument.

Example: A short message
```js
HTMLMAIL('peter@example.com', 'Reset password', '<p>Your code is <b>' + code + '</b>.</p>');
```

### LOGMAIL(address, [subject], body, [callback])

Type: `method`

Sends a log or notification email.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `address` | `String|Array` | yes |  | One email address or an array of addresses; each one becomes a `To` recipient. |
| `subject` | `String` | no | `name and version` | The subject. |
| `body` | `String|Object` | yes |  | The text or an object to serialize. |
| `callback` | `Function` | no |  | Called with `function(err, message)` when the message has been written to the server, or with the reply line when the server rejects it. |

Returns: `MailMessage` The message, before it is sent.

The body is placed in a `<pre>` element; an object is serialized as JSON. Without a subject, the subject is the `name` and the `version` of the configuration, for example `My app v1.0.0`.

Example: Notify the administrator
```js
LOGMAIL('admin@example.com', 'New order', { id: order.id, price: order.price });
```

Example: Only a body
```js
LOGMAIL('admin@example.com', 'The import has finished.');
```

### controller.mail(address, subject, view, [model], [callback])

Type: `method`

Renders a view and sends it as an email from an action.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `address` | `String|Array` | yes |  | One email address or an array of addresses; each one becomes a `To` recipient. |
| `subject` | `String` | yes |  | The subject; `@(...)` parts are translated. |
| `view` | `String` | yes |  | The name of a view in `views/`. |
| `model` | `Object` | no |  | The model of the view. |
| `callback` | `Function` | no |  | Called with `function(err, message)` when the message has been written to the server, or with the reply line when the server rejects it. |

Returns: `MailMessage` The message, before it is sent.

It works like `MAIL()`; the subject is translated with the language of the controller (`this.language`), and the view is rendered with it. The layout of the controller is not used for the email.

Example: After an order
```js
exports.install = function() {
	ROUTE('POST /api/orders/', order);
};

function order() {
	var self = this;
	self.mail(self.body.email, '@(Your order)', 'mails/order', self.body);
	self.success();
}
```

### DEF.onMail = function(address, subject, body, [callback], [replyTo]) {}

Type: `delegate`

Creates and schedules every message of `MAIL()`, `HTMLMAIL()`, `LOGMAIL()` and `controller.mail()`.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `address` | `String|Array` | yes |  | One email address or an array of addresses; each one becomes a `To` recipient. |
| `subject` | `String` | yes |  | The subject. |
| `body` | `String` | yes |  | The HTML body. |
| `callback` | `Function` | no |  | The message callback. |
| `replyTo` | `String` | no |  | A reply-to address instead of `mail_reply`. |

Returns: `MailMessage` The message.

The default delegate creates a message with `Mail.create()`, adds the recipients, sets the sender from `mail_from` and `name`, adds `replyTo` or `mail_reply`, `mail_bcc` and `mail_cc`, and sends it on the next tick with `message.send2()`. Replace it to send email in another way; it must return a message object, because the callers change it (for example with `manually()`).

Example: Add a header to the subject
```js
var onmail = DEF.onMail;

DEF.onMail = function(address, subject, body, callback, replyTo) {
	return onmail(address, '[My app] ' + subject, body, callback, replyTo);
};
```

### ON('mail', function(message) {})

Type: `event`

Emitted for every message just before it is written to the SMTP server.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `message` | `MailMessage` | yes |  | The message being sent. |

It is emitted for messages sent with the configuration and with `Mail.send()`.

Example: Audit outgoing email
```js
ON('mail', function(message) {
	console.log('Mail to', message.address_to, message.subject);
});
```

### CMD('clear_smtpcache')

Type: `command`

Makes the next message read `mail_smtp_options` again.

The options of the SMTP connection are cached after the first message. Run this command after you change `CONF.mail_smtp_options` in code. `LOADCONFIG()` and `Mail.use()` clear the cache themselves.

Example: Change the SMTP account
```js
CONF.mail_smtp = 'smtp.example.com';
CONF.mail_smtp_options = { port: 465, secure: true, user: 'info@example.com', password: 'secret' };
CMD('clear_smtpcache');
```

### mail_smtp : smtp.example.com

Type: `config`

The host name of the SMTP server.

Used by `MAIL()`, `HTMLMAIL()`, `LOGMAIL()`, `controller.mail()`, `message.send2()` and `Mail.send2()`. When it is empty, the framework uses `smtp.` plus the domain of the sender address and stores it here.

Example: In the config file
```text
mail_smtp : smtp.example.com
```

### mail_smtp_options : { port: 465, secure: true, user: '...', password: '...' }

Type: `config`

The options of the SMTP connection.

In the config file it is a JavaScript object written as text; in code it is an object. Options:

- `port` (default `25`, or `465` with `secure`);
- `secure` (default `false`): TLS from the start; the options are also passed to the TLS connection;
- `user` and `password`: the login (`AUTH LOGIN` or `AUTH PLAIN`, as the server offers);
- `token`: an OAuth 2.0 access token for `AUTH XOAUTH2`, used with `user`;
- `tls`: options of the TLS connection; the client upgrades the connection with `STARTTLS`;
- `timeout` (default `10000`): the socket timeout in milliseconds.

With `user` and `password`, a server that announces ESMTP gets `STARTTLS` before the login.

Example: SMTPS
```text
mail_smtp_options : { port: 465, secure: true, user: 'info@example.com', password: 'secret' }
```

Example: Submission port with STARTTLS
```text
mail_smtp_options : { port: 587, user: 'info@example.com', password: 'secret' }
```

Example: OAuth 2.0
```text
mail_smtp_options : { port: 587, user: 'info@example.com', token: 'ya29...' }
```

### mail_smtp_keepalive : 10 minutes

Type: `config`

How long a connection to the SMTP server stays open for the next messages.

Default `10 minutes`. It is used by `message.send2()` while the application runs a web server; the open connection is reused for all messages to the same host. A number is in minutes. `false` opens a new connection for every message.

Example: Close after each message
```text
mail_smtp_keepalive : false
```

### mail_from : info@example.com

Type: `config`

The sender address of messages sent with the configuration.

The sender name is the `name` key of the configuration. `mail_address_from` is an older name of this key.

Example: Sender
```text
name      : My app
mail_from : info@example.com
```

### mail_reply : support@example.com

Type: `config`

A `Reply-To` address added to every message sent with the configuration.

Not used when the caller of `DEF.onMail` passes its own `replyTo`. `mail_address_reply` is an older name of this key.

Example: Reply to support
```text
mail_reply : support@example.com
```

### mail_cc : office@example.com

Type: `config`

A `Cc` address added to every message sent with the configuration.

Example: Copy
```text
mail_cc : office@example.com
```

### mail_bcc : archive@example.com

Type: `config`

A `Bcc` address added to every message sent with the configuration.

`mail_address_copy` is an older name of this key.

Example: Archive every message
```text
mail_bcc : archive@example.com
```

### Mail

Type: `class`

The global mail module: creates messages and sends them over SMTP.

`Mail` is available everywhere. It sends messages to any server (`Mail.send()`), with the configuration (`Mail.send2()`), checks a server (`Mail.try()`, `Mail.use()`) and emits the events `send` and `error`.

Example: A message to any server
```js
var message = Mail.create('Hello', '<p>Hello.</p>');
message.from('info@example.com');
message.to('peter@example.com');
Mail.send('smtp.example.com', { port: 465, secure: true, user: 'info@example.com', password: 'secret' }, [message], NOOP);
```

### Mail.create(subject, body)

Type: `method`

Creates an empty message.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `subject` | `String` | yes |  | The subject. |
| `body` | `String` | yes |  | The body, HTML by default. |

Returns: `MailMessage` A new message.

The message has no sender and no recipients, and its type is `html`. It is not sent until you call `message.send()`, `message.send2()`, `Mail.send()` or `Mail.send2()`.

Example: Create and send
```js
var message = Mail.create('Report', '<p>See the attachment.</p>');
message.from('info@example.com', 'My app');
message.to('peter@example.com');
message.attachment(PATH.root('report.pdf'));
message.send2();
```

### Mail.send(smtp, [options], messages, [callback], [cache])

Type: `method`

Sends one message or an array of messages over one connection.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `smtp` | `String` | yes |  | The host name of the SMTP server. |
| `options` | `Object` | no | `{}` | The connection options, the same as `mail_smtp_options`. |
| `messages` | `MailMessage|Array` | yes |  | A message or an array of messages. |
| `callback` | `Function` | no |  | `function(err)`, called once: when the first message has been written, or when the connection fails. |
| `cache` | `Boolean|Number|String` | no | `false` | Keeps the connection open: `true` for 10 minutes, a number of minutes, or a text such as `5 minutes`. |

Returns: `Mail` The mail module; nothing when the messages join an open connection.

All messages go through one connection in their order. `options` can be skipped when `messages` is an array. With `cache`, the connection stays open and later calls for the same host add their messages to it; such a later call does not call its `callback`, so use `message.callback()` there.

Example: Two messages
```js
Mail.send('smtp.example.com', { port: 465, secure: true, user: 'info@example.com', password: 'secret' }, [a, b], function(err) {
	err && console.log(err);
});
```

### Mail.send2(messages, [callback])

Type: `method`

Sends messages with `mail_smtp` and `mail_smtp_options`.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `messages` | `MailMessage|Array` | yes |  | A message or an array of messages. |
| `callback` | `Function` | no |  | `function(err)`, called once: when the first message has been written, or when the connection fails. Use `message.callback()` for each message. |

Returns: `Mail` The mail module.

The same as `Mail.send()` with the server and the options of the configuration.

Example: A newsletter
```js
var messages = users.map(function(user) {
	var message = Mail.create('News', html);
	message.from(CONF.mail_from, CONF.name);
	message.to(user.email);
	return message;
});

Mail.send2(messages, function(err) {
	err && console.log(err);
});
```

### Mail.try(smtp, [options], [callback])

Type: `method`

Checks an SMTP server: connects, signs in and quits.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `smtp` | `String` | yes |  | The host name of the SMTP server. |
| `options` | `Object` | no | `{}` | The connection options, the same as `mail_smtp_options`. |
| `callback` | `Function` | no |  | `function(err)`. |

Returns: `Mail|Promise` The mail module, or a promise without a callback.

No message is sent. Without a callback it returns a promise that is rejected with the error.

Example: With a callback
```js
Mail.try('smtp.example.com', { port: 465, secure: true, user: 'info@example.com', password: 'secret' }, function(err) {
	console.log(err ? 'Failed' : 'Works');
});
```

Example: With a promise
```js
try {
	await Mail.try('smtp.example.com', { port: 587, user: 'info@example.com', password: 'secret' });
} catch (err) {
	console.log('SMTP failed', err);
}
```

### Mail.use(smtp, [options], [callback])

Type: `method`

Checks an SMTP server and, when it works, makes it the server of the configuration.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `smtp` | `String` | yes |  | The host name of the SMTP server. |
| `options` | `Object` | no |  | The connection options. |
| `callback` | `Function` | no |  | `function(err)`. |

It calls `Mail.try()`; on success it sets `CONF.mail_smtp` and `CONF.mail_smtp_options` and clears the cached options. Without a callback, an error is logged with `F.error()`.

Example: Settings from a database
```js
Mail.use(settings.smtp, settings.smtpoptions, function(err) {
	err && console.log('SMTP is not available', err);
});
```

### Mail.debug = true

Type: `property`

Prints the SMTP conversation to the console.

Returns: `Boolean`

Default `false`. Every command sent and every reply received is printed.

Example: Debug a server
```js
Mail.debug = true;
```

### Mail.on('error', function(err, connection) {})

Type: `event`

Emitted when a connection or an SMTP command fails.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `err` | `Error|String` | yes |  | The error or the reply line of the server. |
| `connection` | `Object` | yes |  | The internal connection object. |

Not emitted for `Mail.try()` or for a connection reset. A message rejected by the server is passed as its reply line.

Example: Log SMTP errors
```js
Mail.on('error', function(err) {
	console.log('SMTP error', err);
});
```

### Mail.on('send', function(connection) {})

Type: `event`

Emitted when a connection to the SMTP server is ready and the client starts the conversation.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `connection` | `Object` | yes |  | The internal connection object. |

Example: Count connections
```js
Mail.on('send', function() {
	console.log('SMTP connection');
});
```

### Mail.removeListener(name, fn)

Type: `method`

Removes a handler of a `Mail` event.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `name` | `String` | yes |  | The event name, `error` or `send`. |
| `fn` | `Function` | yes |  | The handler added with `Mail.on()`. |

Returns: `Mail` The mail module.

`Mail.once(name, fn)` adds a handler that runs once; `Mail.removeAllListeners([name])` removes all handlers of one event or of all events.

Example: Stop logging
```js
function log(err) {
	console.log(err);
}

Mail.on('error', log);
Mail.removeListener('error', log);
```

### message.to(address, [name], [clear])

Type: `method`

Adds a `To` recipient.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `address` | `String` | yes |  | The email address. |
| `name` | `String` | no |  | The name of the recipient. |
| `clear` | `Boolean` | no | `false` | Removes the recipients added before. |

Returns: `MailMessage` The message.

The address can contain the name: `Peter Sirka <peter@example.com>`. `clear` can be the second argument.

Example: Two recipients
```js
message.to('peter@example.com', 'Peter');
message.to('Lucia <lucia@example.com>');
```

### message.cc(address, [name], [clear])

Type: `method`

Adds a `Cc` recipient.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `address` | `String` | yes |  | The email address. |
| `name` | `String` | no |  | The name of the recipient. |
| `clear` | `Boolean` | no | `false` | Removes the `Cc` addresses added before. |

Returns: `MailMessage` The message.

The address can contain the name, like in `message.to()`. `clear` can be the second argument.

Example: A copy
```js
message.cc('office@example.com');
```

### message.bcc(address, [clear])

Type: `method`

Adds a `Bcc` recipient.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `address` | `String` | yes |  | The email address. |
| `clear` | `Boolean` | no | `false` | Removes the `Bcc` addresses added before, including `mail_bcc`. |

Returns: `MailMessage` The message.

The address is not written to the headers. Use a plain address without a name.

Example: A hidden copy
```js
message.bcc('archive@example.com');
```

### message.reply(address, [clear])

Type: `method`

Adds a `Reply-To` address.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `address` | `String` | yes |  | The email address. |
| `clear` | `Boolean` | no | `false` | Removes the reply addresses added before, including `mail_reply`. |

Returns: `MailMessage` The message.

Use a plain address without a name.

Example: Replace the configured address
```js
message.reply('billing@example.com', true);
```

### message.from(address, [name])

Type: `method`

Sets the sender.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `address` | `String` | yes |  | The email address. |
| `name` | `String` | no |  | The name of the sender. |

Returns: `MailMessage` The message.

The address can contain the name: `My app <info@example.com>`. Messages created by `MAIL()` and the other global functions already have the sender from `mail_from` and `name`.

Example: Sender with a name
```js
message.from('info@example.com', 'My app');
```

### message.sender(address, [name])

Type: `method`

An alias of `message.from()`.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `address` | `String` | yes |  | The email address. |
| `name` | `String` | no |  | The name of the sender. |

Returns: `MailMessage` The message.

Example: Sender
```js
message.sender('info@example.com', 'My app');
```

### message.subject

Type: `property`

The subject of the message.

Returns: `String`

You can change it before the message is sent. Non-ASCII characters are encoded for you.

Example: Prefix
```js
message.subject = '[Test] ' + message.subject;
```

### message.body

Type: `property`

The body of the message.

Returns: `String`

HTML by default; see `message.type`.

Example: Set the body later
```js
var message = HTMLMAIL('peter@example.com', 'Report', '');
message.manually();
render(function(html) {
	message.body = html;
	message.send2();
});
```

### message.type

Type: `property`

The content type of the body: `html` or `plain`.

Returns: `String`

Default `html`. The body is sent as `text/` plus this value.

Example: A plain text message
```js
var message = Mail.create('Hello', 'Hello,\nthis is plain text.');
message.type = 'plain';
```

### message.attachment(filename, [name], [contentid])

Type: `method`

Adds a file from the disk as an attachment.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `filename` | `String` | yes |  | The path of the file. |
| `name` | `String` | no | `the name of the file` | The file name shown in the email. |
| `contentid` | `String` | no |  | A Content-ID for an inline attachment, unique in the message. |

Returns: `MailMessage` The message.

The content type comes from the extension of `name`. With `contentid`, the file is an inline attachment and the HTML refers to it as `cid:contentid`. An `.ics` file is sent as a calendar invitation.

Example: A PDF
```js
message.attachment(PATH.root('invoices/2024-001.pdf'), 'invoice.pdf');
```

Example: An inline image
```js
var message = HTMLMAIL('peter@example.com', 'Report', '<img src="cid:chart1" />');
message.attachment(PATH.public('img/chart.png'), 'chart.png', 'chart1');
```

### message.attachmentfs(storage, id, [name], [contentid])

Type: `method`

Adds a file from a `FILESTORAGE()` as an attachment.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `storage` | `String` | yes |  | The name of the file storage. |
| `id` | `String` | yes |  | The identifier of the file. |
| `name` | `String` | no | `the stored name` | The file name shown in the email. |
| `contentid` | `String` | no |  | A Content-ID for an inline attachment. |

Returns: `MailMessage` The message.

Without `name`, the name and the content type come from the stored file. A file that cannot be read is skipped and the error is logged.

Example: A stored file
```js
message.attachmentfs('documents', doc.fileid);
```

### message.unsubscribe(url)

Type: `method`

Adds the `List-Unsubscribe` headers.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `url` | `String` | yes |  | An unsubscribe URL or email address. |

Returns: `MailMessage` The message.

A URL that starts with `http:` or `https:` is used as a link; any other value is used as a `mailto:` address. The header `List-Unsubscribe-Post: List-Unsubscribe=One-Click` is added too.

Example: A newsletter
```js
message.unsubscribe('https://example.com/unsubscribe/?id=' + user.id);
```

### message.callback(fn)

Type: `method`

Sets the callback of the message.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `fn` | `Function` | yes |  | `function(err, message)`. |

Returns: `MailMessage` The message.

The callback runs when the message has been written to the server, or when the server rejects it; the error is then the reply line of the server. Connection errors are not passed here: they are logged and emitted as `Mail.on('error')`.

Example: Mark as sent
```js
message.callback(function(err) {
	if (!err)
		NOSQL('orders').modify({ mailed: true }).id(order.id);
});
```

### message.manually()

Type: `method`

Stops the automatic sending of a message from `MAIL()`, `HTMLMAIL()`, `LOGMAIL()` or `controller.mail()`.

Returns: `MailMessage` The message.

Call it in the same call stack, then send the message yourself with `message.send2()`.

Example: Attach a generated file
```js
var message = HTMLMAIL('peter@example.com', 'Export', '<p>The file is attached.</p>');
message.manually();

createexport(function(filename) {
	message.attachment(filename, 'export.csv');
	message.send2();
});
```

### message.send2([callback])

Type: `method`

Sends the message with `mail_smtp` and `mail_smtp_options`.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `callback` | `Function` | no |  | Called when the message has been written, on a new connection. |

Returns: `MailMessage` The message.

Without `mail_smtp`, the server is `smtp.` plus the domain of the sender; without a sender it throws `Missing SMTP settings`. While the application runs a web server, the connection is kept open for `mail_smtp_keepalive`; when the message goes to such an open connection, `callback` is not called, so prefer `message.callback()`.

Example: Send a created message
```js
var message = Mail.create('Hello', '<p>Hello.</p>');
message.from(CONF.mail_from, CONF.name);
message.to('peter@example.com');
message.callback(function(err) {
	err && console.log(err);
});
message.send2();
```

### message.send(smtp, options, [callback], [cache])

Type: `method`

Sends the message to an SMTP server.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `smtp` | `String` | yes |  | The host name of the SMTP server. |
| `options` | `Object` | yes |  | The connection options, the same as `mail_smtp_options`; pass `{}` for none. |
| `callback` | `Function` | no |  | `function(err, message)`. |
| `cache` | `Boolean|Number|String` | no | `false` | Keeps the connection open, like in `Mail.send()`. |

Returns: `MailMessage` The message.

Uses its own connection to `smtp`; the configuration is not used.

Example: Another server
```js
message.send('smtp.example.com', { port: 465, secure: true, user: 'info@example.com', password: 'secret' }, function(err) {
	console.log(err ? 'Failed' : 'Sent');
});
```
