Options
All
  • Public
  • Public/Protected
  • All
Menu

Creates a new mime tree node. Assumes 'multipart/*' as the content type if it is a branch, anything else counts as leaf. If rootNode is missing from the options, assumes this is the root.

Hierarchy

  • MimeNode

Index

Constructors

constructor

  • Parameters

    • contentType: string
    • Optional options: Options

    Returns MimeNode

Methods

addHeader

  • addHeader(key: string, value: string): this
  • addHeader(headers: object | Array<object>): this
  • Adds a header value. If the value for selected key exists, the value is appended as a new field and old one is not touched. You can set multiple values as well by using [{key:'', value:''}] or {key: 'value'} as the first argument.

    Parameters

    • key: string
    • value: string

    Returns this

  • Parameters

    • headers: object | Array<object>

    Returns this

appendChild

  • Appends an existing node to the mime tree. Removes the node from an existing tree if needed

    Parameters

    Returns MimeNode

build

  • build(callback: function): void
  • Generate the message and return it with a callback

    Parameters

    • callback: function
        • (err: Error | null, buf: Buffer): void
        • Parameters

          • err: Error | null
          • buf: Buffer

          Returns void

    Returns void

buildHeaders

  • buildHeaders(): string
  • Builds the header block for the mime node. Append \r\n\r\n before writing the content

    Returns string

createChild

  • Creates and appends a child node.Arguments provided are passed to MimeNode constructor

    Parameters

    • contentType: string
    • Optional options: Options

    Returns MimeNode

createReadStream

  • Streams the rfc2822 message from the current node. If this is a root node, mandatory header fields are set if missing (Date, Message-Id, MIME-Version)

    Parameters

    Returns Readable

getAddresses

  • Generates and returns an object with parsed address fields

    Returns Addresses

getEnvelope

  • Generates and returns SMTP envelope with the sender address and a list of recipients addresses

    Returns Envelope

getHeader

  • getHeader(key: string): string
  • Retrieves the first mathcing value of a selected key

    Parameters

    • key: string

    Returns string

getTransferEncoding

  • getTransferEncoding(): string
  • Returns string

processFunc

  • processFunc(processFunc: function): void
  • Appends a post process function. The functon is run after transforms and uses the following syntax

    processFunc(input) -> outputStream

    Parameters

    Returns void

remove

  • remove(): this
  • Removes current node from the mime tree

    Returns this

replace

  • Replaces current node with another node

    Parameters

    Returns MimeNode

setContent

  • Sets body content for current node. If the value is a string, charset is added automatically to Content-Type (if it is text/*). If the value is a Buffer, you need to specify the charset yourself

    Parameters

    Returns this

setEnvelope

  • Sets envelope to be used instead of the generated one

    Parameters

    Returns this

setHeader

  • setHeader(key: string, value: string | string[]): this
  • setHeader(headers: object | Array<object>): this
  • Sets a header value. If the value for selected key exists, it is overwritten. You can set multiple values as well by using [{key:'', value:''}] or {key: 'value'} as the first argument.

    Parameters

    • key: string
    • value: string | string[]

    Returns this

  • Parameters

    • headers: object | Array<object>

    Returns this

setRaw

  • Sets pregenerated content that will be used as the output of this node

    Parameters

    Returns this

stream

  • Parameters

    • outputStream: Readable
    • options: ReadableOptions
    • done: function
        • (err?: Error | null): void
        • Parameters

          • Optional err: Error | null

          Returns void

    Returns void

transform

  • Appends a transform stream object to the transforms list. Final output is passed through this stream before exposing

    Parameters

    Returns void

Generated using TypeDoc