Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

preview-email

Package Overview
Dependencies
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

preview-email

Automatically opens your browser to preview Node.js email messages sent with Nodemailer. Made for Lad!

  • 2.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
163K
decreased by-44.63%
Maintainers
1
Weekly downloads
 
Created

What is preview-email?

The preview-email npm package allows developers to preview email templates during development. It is particularly useful for testing and debugging email content before sending it to actual recipients.

What are preview-email's main functionalities?

Preview Email in Browser

This feature allows you to preview an email in the browser. The email object contains the necessary fields like 'from', 'to', 'subject', and 'html'. The previewEmail function generates a preview URL that you can open in your browser.

const previewEmail = require('preview-email');
const email = {
  from: 'sender@example.com',
  to: 'recipient@example.com',
  subject: 'Test Email',
  html: '<h1>Hello World</h1>'
};

previewEmail(email).then(console.log).catch(console.error);

Custom Template Rendering

This feature allows you to use custom template engines like EJS to render dynamic email content. The rendered HTML is then passed to the previewEmail function for previewing.

const previewEmail = require('preview-email');
const ejs = require('ejs');
const emailTemplate = '<h1>Hello <%= name %></h1>';
const emailData = { name: 'John Doe' };
const emailHtml = ejs.render(emailTemplate, emailData);
const email = {
  from: 'sender@example.com',
  to: 'recipient@example.com',
  subject: 'Personalized Email',
  html: emailHtml
};

previewEmail(email).then(console.log).catch(console.error);

Inline CSS

This feature allows you to inline CSS styles in your email HTML using the 'juice' library. The inlined HTML is then passed to the previewEmail function for previewing.

const previewEmail = require('preview-email');
const juice = require('juice');
const emailHtml = '<style>h1 { color: red; }</style><h1>Hello World</h1>';
const inlinedHtml = juice(emailHtml);
const email = {
  from: 'sender@example.com',
  to: 'recipient@example.com',
  subject: 'Styled Email',
  html: inlinedHtml
};

previewEmail(email).then(console.log).catch(console.error);

Other packages similar to preview-email

Keywords

FAQs

Package last updated on 17 Feb 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc