> ## Documentation Index
> Fetch the complete documentation index at: https://projectdiscovery-subfinder-reference-blog.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Smtp

<a name="module_smtp" />

## smtp

* [smtp](#module_smtp)
  * [`SMTPClient`](#module_smtp..SMTPClient)
    * [`.IsOpenRelay(host, port, msg)`](#module_smtp..SMTPClient+IsOpenRelay) ⇒ <code>boolean</code>
    * [`.IsSMTP(host, port)`](#module_smtp..SMTPClient+IsSMTP) ⇒ <code>IsSMTPResponse</code>
    * [`.SendMail(host, port, msg)`](#module_smtp..SMTPClient+SendMail) ⇒ <code>boolean</code>
  * [`SMTPMessage`](#module_smtp..SMTPMessage)
    * [`.Auth(username, password)`](#module_smtp..SMTPMessage+Auth) ⇒ <code>SMTPMessage</code>
    * [`.Body(msg)`](#module_smtp..SMTPMessage+Body) ⇒ <code>SMTPMessage</code>
    * [`.From(email)`](#module_smtp..SMTPMessage+From) ⇒ <code>SMTPMessage</code>
    * [`.String()`](#module_smtp..SMTPMessage+String) ⇒ <code>string</code>
    * [`.Subject(sub)`](#module_smtp..SMTPMessage+Subject) ⇒ <code>SMTPMessage</code>
    * [`.To(email)`](#module_smtp..SMTPMessage+To) ⇒ <code>SMTPMessage</code>

<a name="module_smtp..SMTPClient" />

### (smtp).SMTPClient

SMTPClient is a minimal SMTP client for nuclei scripts.

**Kind**: inner class of [<code>smtp</code>](#module_smtp)

* [`SMTPClient`](#module_smtp..SMTPClient)
  * [`.IsOpenRelay(host, port, msg)`](#module_smtp..SMTPClient+IsOpenRelay) ⇒ <code>boolean</code>
  * [`.IsSMTP(host, port)`](#module_smtp..SMTPClient+IsSMTP) ⇒ <code>IsSMTPResponse</code>
  * [`.SendMail(host, port, msg)`](#module_smtp..SMTPClient+SendMail) ⇒ <code>boolean</code>

<a name="module_smtp..SMTPClient+IsOpenRelay" />

#### smtpClient.IsOpenRelay(host, port, msg) ⇒ <code>boolean</code>

IsOpenRelay checks if a host is an open relay

**Kind**: instance method of [<code>SMTPClient</code>](#module_smtp..SMTPClient)\
**Returns**: <code>boolean</code> - - Whether the host is an open relay or not.\
**Throws**:

* <code>error</code> - The error encountered during the check.

| Param | Type                | Description          |
| ----- | ------------------- | -------------------- |
| host  | <code>string</code> | The host to check.   |
| port  | <code>number</code> | The port to check.   |
| msg   | <code>string</code> | The message to send. |

**Example**

```js
let m = require('nuclei/smtp');
    let c = m.SMTPClient();
    let isOpenRelay = c.IsOpenRelay('localhost', 25, 'test message');
```

<a name="module_smtp..SMTPClient+IsSMTP" />

#### smtpClient.IsSMTP(host, port) ⇒ <code>IsSMTPResponse</code>

IsSMTP checks if a host is running a SMTP server.

**Kind**: instance method of [<code>SMTPClient</code>](#module_smtp..SMTPClient)\
**Returns**: <code>IsSMTPResponse</code> - - The response from the SMTP server.\
**Throws**:

* <code>error</code> - The error encountered during the check.

| Param | Type                | Description        |
| ----- | ------------------- | ------------------ |
| host  | <code>string</code> | The host to check. |
| port  | <code>number</code> | The port to check. |

**Example**

```js
let m = require('nuclei/smtp');
    let c = m.SMTPClient();
    let isSMTP = c.IsSMTP('localhost', 25);
```

<a name="module_smtp..SMTPClient+SendMail" />

#### smtpClient.SendMail(host, port, msg) ⇒ <code>boolean</code>

SendMail sends an email using the SMTP protocol.

**Kind**: instance method of [<code>SMTPClient</code>](#module_smtp..SMTPClient)\
**Returns**: <code>boolean</code> - - Whether the email was sent successfully or not.\
**Throws**:

* <code>error</code> - The error encountered during the email sending.

| Param | Type                | Description                    |
| ----- | ------------------- | ------------------------------ |
| host  | <code>string</code> | The host to send the email to. |
| port  | <code>number</code> | The port to send the email to. |
| msg   | <code>string</code> | The message to send.           |

**Example**

```js
let m = require('nuclei/smtp');
    let c = m.SMTPClient();
    let isSent = c.SendMail('localhost', 25, 'test message');
```

<a name="module_smtp..SMTPMessage" />

### (smtp).SMTPMessage

SMTPMessage is a simple smtp message builder

**Kind**: inner class of [<code>smtp</code>](#module_smtp)

* [`SMTPMessage`](#module_smtp..SMTPMessage)
  * [`.Auth(username, password)`](#module_smtp..SMTPMessage+Auth) ⇒ <code>SMTPMessage</code>
  * [`.Body(msg)`](#module_smtp..SMTPMessage+Body) ⇒ <code>SMTPMessage</code>
  * [`.From(email)`](#module_smtp..SMTPMessage+From) ⇒ <code>SMTPMessage</code>
  * [`.String()`](#module_smtp..SMTPMessage+String) ⇒ <code>string</code>
  * [`.Subject(sub)`](#module_smtp..SMTPMessage+Subject) ⇒ <code>SMTPMessage</code>
  * [`.To(email)`](#module_smtp..SMTPMessage+To) ⇒ <code>SMTPMessage</code>

<a name="module_smtp..SMTPMessage+Auth" />

#### smtpMessage.Auth(username, password) ⇒ <code>SMTPMessage</code>

Auth when called authenticates using username and password before sending the message

**Kind**: instance method of [<code>SMTPMessage</code>](#module_smtp..SMTPMessage)\
**Returns**: <code>SMTPMessage</code> - - The SMTPMessage object after authentication.

| Param    | Type                | Description                      |
| -------- | ------------------- | -------------------------------- |
| username | <code>string</code> | The username for authentication. |
| password | <code>string</code> | The password for authentication. |

**Example**

```js
let m = require('nuclei/smtp');
    let msg = m.SMTPMessage();
    msg = msg.Auth('username', 'password');
```

<a name="module_smtp..SMTPMessage+Body" />

#### smtpMessage.Body(msg) ⇒ <code>SMTPMessage</code>

Body adds the message body to the message

**Kind**: instance method of [<code>SMTPMessage</code>](#module_smtp..SMTPMessage)\
**Returns**: <code>SMTPMessage</code> - - The SMTPMessage object after adding the body.

| Param | Type                | Description              |
| ----- | ------------------- | ------------------------ |
| msg   | <code>string</code> | The message body to add. |

**Example**

```js
let m = require('nuclei/smtp');
    let msg = m.SMTPMessage();
    msg = msg.Body('This is a test message');
```

<a name="module_smtp..SMTPMessage+From" />

#### smtpMessage.From(email) ⇒ <code>SMTPMessage</code>

From adds the from field to the message

**Kind**: instance method of [<code>SMTPMessage</code>](#module_smtp..SMTPMessage)\
**Returns**: <code>SMTPMessage</code> - - The SMTPMessage object after adding the from field.

| Param | Type                | Description                         |
| ----- | ------------------- | ----------------------------------- |
| email | <code>string</code> | The email to add to the from field. |

**Example**

```js
let m = require('nuclei/smtp');
    let msg = m.SMTPMessage();
    msg = msg.From('test@example.com');
```

<a name="module_smtp..SMTPMessage+String" />

#### smtpMessage.String() ⇒ <code>string</code>

String returns the string representation of the message

**Kind**: instance method of [<code>SMTPMessage</code>](#module_smtp..SMTPMessage)\
**Returns**: <code>string</code> - - The string representation of the message.\
**Example**

```js
let m = require('nuclei/smtp');
    let msg = m.SMTPMessage();
    let str = msg.String();
```

<a name="module_smtp..SMTPMessage+Subject" />

#### smtpMessage.Subject(sub) ⇒ <code>SMTPMessage</code>

Subject adds the subject field to the message

**Kind**: instance method of [<code>SMTPMessage</code>](#module_smtp..SMTPMessage)\
**Returns**: <code>SMTPMessage</code> - - The SMTPMessage object after adding the subject.

| Param | Type                | Description         |
| ----- | ------------------- | ------------------- |
| sub   | <code>string</code> | The subject to add. |

**Example**

```js
let m = require('nuclei/smtp');
    let msg = m.SMTPMessage();
    msg = msg.Subject('Test Subject');
```

<a name="module_smtp..SMTPMessage+To" />

#### smtpMessage.To(email) ⇒ <code>SMTPMessage</code>

To adds the to field to the message

**Kind**: instance method of [<code>SMTPMessage</code>](#module_smtp..SMTPMessage)\
**Returns**: <code>SMTPMessage</code> - - The SMTPMessage object after adding the to field.

| Param | Type                | Description                       |
| ----- | ------------------- | --------------------------------- |
| email | <code>string</code> | The email to add to the to field. |

**Example**

```js
let m = require('nuclei/smtp');
    let msg = m.SMTPMessage();
    msg = msg.To('test@example.com');
```
