> For the complete documentation index, see [llms.txt](https://docs.rulecube.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.rulecube.com/v2.5/language-reference/mail.md).

# Mail

Collection of e-mail functions.

### Methods

#### send

```javascript
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**

&#x20;   **smtpSettings&#x20;*****{ host: string, port?: number, auth?: { user: string, pass: string }, secure?: boolean }***

&#x20;       The SMTP connection settings.

&#x20;   **mailOptions&#x20;*****{ 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 }\[] }***

&#x20;       The mail options. Includes the from, to, subject, text and html properties.

**Return type**

&#x20;   { accepted: string\[], rejected: string\[], envelopeTime: number, messageTime: number, messageSize: number, response: string, envelope: { from: string, to: string\[] } }

**Examples**

```javascript
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]' },
  ]
})
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.rulecube.com/v2.5/language-reference/mail.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
