smtp

(smtp).SMTPClient

SMTPClient is a minimal SMTP client for nuclei scripts.

Kind: inner class of smtp

smtpClient.IsOpenRelay(host, port, msg) ⇒ boolean

IsOpenRelay checks if a host is an open relay

Kind: instance method of SMTPClient
Returns: boolean - - Whether the host is an open relay or not.
Throws:

  • error - The error encountered during the check.
ParamTypeDescription
hoststringThe host to check.
portnumberThe port to check.
msgstringThe message to send.

Example

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

smtpClient.IsSMTP(host, port) ⇒ IsSMTPResponse

IsSMTP checks if a host is running a SMTP server.

Kind: instance method of SMTPClient
Returns: IsSMTPResponse - - The response from the SMTP server.
Throws:

  • error - The error encountered during the check.
ParamTypeDescription
hoststringThe host to check.
portnumberThe port to check.

Example

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

smtpClient.SendMail(host, port, msg) ⇒ boolean

SendMail sends an email using the SMTP protocol.

Kind: instance method of SMTPClient
Returns: boolean - - Whether the email was sent successfully or not.
Throws:

  • error - The error encountered during the email sending.
ParamTypeDescription
hoststringThe host to send the email to.
portnumberThe port to send the email to.
msgstringThe message to send.

Example

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

(smtp).SMTPMessage

SMTPMessage is a simple smtp message builder

Kind: inner class of smtp

smtpMessage.Auth(username, password) ⇒ SMTPMessage

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

Kind: instance method of SMTPMessage
Returns: SMTPMessage - - The SMTPMessage object after authentication.

ParamTypeDescription
usernamestringThe username for authentication.
passwordstringThe password for authentication.

Example

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

smtpMessage.Body(msg) ⇒ SMTPMessage

Body adds the message body to the message

Kind: instance method of SMTPMessage
Returns: SMTPMessage - - The SMTPMessage object after adding the body.

ParamTypeDescription
msgstringThe message body to add.

Example

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

smtpMessage.From(email) ⇒ SMTPMessage

From adds the from field to the message

Kind: instance method of SMTPMessage
Returns: SMTPMessage - - The SMTPMessage object after adding the from field.

ParamTypeDescription
emailstringThe email to add to the from field.

Example

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

smtpMessage.String() ⇒ string

String returns the string representation of the message

Kind: instance method of SMTPMessage
Returns: string - - The string representation of the message.
Example

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

smtpMessage.Subject(sub) ⇒ SMTPMessage

Subject adds the subject field to the message

Kind: instance method of SMTPMessage
Returns: SMTPMessage - - The SMTPMessage object after adding the subject.

ParamTypeDescription
substringThe subject to add.

Example

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

smtpMessage.To(email) ⇒ SMTPMessage

To adds the to field to the message

Kind: instance method of SMTPMessage
Returns: SMTPMessage - - The SMTPMessage object after adding the to field.

ParamTypeDescription
emailstringThe email to add to the to field.

Example

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