1.1.1 • Published 8 months ago

email-viewer v1.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

Email viewer

NPM Version NPM Downloads License code style: prettier

Opens browser with email preview by rendering HTML file using bundled EJS template.

Preview

Email example from React Email

image

Installation

npm install email-viewer

Example usage

Here is an example of how to use the viewEmail function:

const message = {
  subject: "test subject",
  text: "Hello, world!",
}

if (process.env.NODE_ENV === "development") {
  return import("email-viewer").then(({ viewEmail }) => viewEmail(message))
}

Options

The viewEmail function accepts an object with the following properties:

ViewEmailOptions

PropertyTypeDescriptionDefault
idstringID of the email. If not provided, a random UUID will be generated.randomUUID()
dirstringDirectory where the HTML file will be saved. If open is set to false, the file will not be created.os.tmpdir()
openbooleanWhether to automatically open the rendered HTML file in the default browser.true
subjectstringSubject of the email.undefined
fromstringSender of the email.undefined
tostring \| string[]Recipient(s) of the email.undefined
htmlstringHTML content of the email.undefined
textstringPlain text content of the email.undefined

Result

The viewEmail function returns an object with the following properties:

ViewEmailResult

PropertyTypeDescription
idstringID of the email.
htmlstringRendered HTML content.

License

MIT

1.1.1

8 months ago

1.1.0

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago

0.0.0

1 year ago

2.0.3

6 years ago

2.0.2

6 years ago

2.0.1

6 years ago

2.0.0

6 years ago