Represents an attachment. This interface is compatible with Attachment of nodemailer.

interface Attachment {
    cid?: string;
    content?: string | Buffer | Readable;
    contentDisposition?: "attachment" | "inline";
    contentTransferEncoding?:
        | false
        | "7bit"
        | "base64"
        | "quoted-printable";
    contentType?: string;
    encoding?: string;
    filename?: string | false;
    headers?: Headers;
    path?: string | Url;
    raw?:
        | string
        | Buffer
        | Readable
        | AttachmentLike;
}

Hierarchy (view full)

Properties

cid?: string

Optional content id for using inline images in HTML message source. Using cid sets the default contentDisposition to 'inline' and moves the attachment into a multipart/related MIME node, so use it only if you actually want to use this attachment as an embedded image.

content?: string | Buffer | Readable

Contents of the attachment stored in a string, buffer or stream.

contentDisposition?: "attachment" | "inline"

Content disposition type of the attachment. Defaults to attachment.

contentTransferEncoding?:
    | false
    | "7bit"
    | "base64"
    | "quoted-printable"

Encoding for the attachment transfer. Will be derived from the contentType property, if not set. Example values: quoted-printable, base64. If it is unset then base64 encoding is used for the attachment. If set to false, the previous default applies (base64 for most, 7bit for text).

contentType?: string

Content type of the attachment. Will be derived from the filename property, if not set.

encoding?: string

Encoding used to encode the content to a buffer. Example values: base64, hex, binary etc. Useful if you want to use binary attachments in a JSON formatted e-mail object.

filename?: string | false

Filename to be reported as the name of the attached file, use of unicode is allowed. If you do not want to use a filename, set this value to false, otherwise a filename is generated automatically.

headers?: Headers

Additional headers to be sent with the attachment.

path?: string | Url

File path or URL (data URIs are allowed as well) if you want to read a file instead of including it (better for larger attachments).

raw?:
    | string
    | Buffer
    | Readable
    | AttachmentLike

A raw value that overrides entire node content in the MIME message. If used, all other options set for this node are ignored.

Copyright Ⓒ 2024 SAP SE or an SAP affiliate company. All rights reserved.