Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

haraka-email-message

haraka7.1kMIT1.2.5

Haraka email message

haraka, email-message

readme

CI Test Status Code Climate

haraka-email-message

USAGE

const message = require('haraka-email-message')
new message.Header(options)
new message.Body(header, options)
new message.stream(cfg, uuid, header_list)

Exports

=============

The Header object gives programmatic access to email headers. It is primarily used from transaction.header but also each MIME part of the Body will also have its own header object.

API

  • header.get(key)

Returns the header with the name key. If there are multiple headers with the given name (as is usually the case with "Received" for example) they will be concatenated together with "\n".

  • header.get_all(key)

Returns the headers with the name key as an array. Multi-valued headers will have multiple entries in the array.

  • header.get_decoded(key)

Works like get(key), only it gives you headers decoded from any MIME encoding they may have used.

  • header.remove(key)

Removes all headers with the given name. DO NOT USE. This is transparent to the transaction and it will not see the header(s) you removed. Instead use transaction.remove_header(key) which will also correct the data part of the email.

  • header.add(key, value)

Adds a header with the given name and value. DO NOT USE. This is transparent to the transaction and it will not see the header you added. Instead use transaction.add_header(key, value) which will add the header to the data part of the email.

  • header.lines()

Returns the entire header as a list of lines.

  • header.toString()

Returns the entire header as a string.

Body

===========

Email Message Body provides access to the textual body parts of an email.

API

  • body.bodytext

A String containing the body text. Note that HTML parts will have tags in-tact.

  • body.header

The header of this MIME part. See the Header Object for details of the API.

  • body.children

Any child MIME parts. For example a multipart/alternative mail will have a main body part with just the MIME preamble in (which is usually either empty, or reads something like "This is a multipart MIME message"), and two children, one text/plain and one text/html.

changelog

Changelog

The format is based on Keep a Changelog.

Unreleased

1.2.5 - 2025-01-31

  • dep(all): bump to latest
  • dep(eslint): upgrade to v9
  • style(prettier): move config into package.json

1.2.4 - 2024-09-27

  • allow attachment filenames containing semicolons #13

1.2.3 - 2024-04-24

  • style(es6): replace forEach with for...of
  • doc(CONTRIBUTORS): added

1.2.2 - 2024-04-07

  • dep: eslint-plugin-haraka -> @haraka/eslint-config
  • lint: updated .eslintrc
  • package.json: updated scripts
  • prettier

1.2.1 - 2024-04-03

  • dep(libqp): bump to 2.1.0
  • dep(libmime): bump to 5.3.4
  • dep(haraka-message-stream): bump to 1.2.1
  • dep(mocha & eslint): remove from devDeps (install as needed with npx)
  • add ./test to .npmignore

1.2.0 - 2022-11-29

  • dep(libqp): update from 1.1 -> 2.0.1

1.1.0 - 2022-09-14

  • Do not insert banner in text attachments, #3
  • chore(climate): configure code climate

1.0.0 - 2022-06-24