New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

format-mail

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

format-mail

Formatter for email, make your email looks beautiful!

  • 1.2.0
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-94.44%
Maintainers
1
Weekly downloads
 
Created
Source

Format-Mail ✉️

Formatter for email, making your email look beautiful! 😍

ℹ️ Info

Format-Mail is a simple Node.js module for formatting email contents. With this module, you can add images, headings, and styles to your email to make it visually appealing. It is specifically designed for use with Nodemailer, a popular email sending library.

Installation

npm install format-mail@latest

Or, if you prefer using Yarn:

yarn add format-mail@latest

Basic Formatting Example (JavaScript)

'use strict';
const nodemailer = require('nodemailer');
const { emailFormatter, HTMLTags } = require('format-mail');

const transporter = nodemailer.createTransport({
  host: 'smtp.forwardemail.net',
  port: 465,
  secure: true,
  auth: {
    // TODO: Replace `user` and `pass` values from <https://forwardemail.net>
    user: 'REPLACE-WITH-YOUR-ALIAS@YOURDOMAIN.COM',
    pass: 'REPLACE-WITH-YOUR-GENERATED-PASSWORD',
  },
});

// async..await is not allowed in the global scope, so we wrap the code in an async function
async function main() {
  // Send mail with the defined transport object
  const info = await transporter.sendMail({
    from: '"Fred Foo 👻" <foo@example.com>', // Sender address
    to: 'bar@example.com, baz@example.com', // List of receivers
    subject: 'Hello ✔', // Subject line
    text: 'Hello world?', // Plain text body
    html: `${emailFormatter.bold('Hello world?')}\n${HTMLTags.heading1(
      'Hello world!',
      'text-align: center',
      'display: flex',
      'justify-contents: center',
      'align-items: center'
    )}`, // HTML body with formatted text and basic styles
  });

  console.log('Message sent: %s', info.messageId);
  // Output: Message sent: <b658f8ca-6296-ccf4-8306-87d57a0b4321@example.com>

  //
  // NOTE: You can go to https://forwardemail.net/my-account/emails to see the delivery status and preview of your email.
  //       Alternatively, you can use the "preview-email" npm package to preview emails locally in browsers and iOS Simulator.
  //       Check out the repository at <https://github.com/forwardemail/preview-email>.
  //
}

main().catch(console.error);

Basic Formatting Example (TypeScript)

import * as nodemailer from 'nodemailer';
import { emailFormatter, HTMLTags } from 'format-mail';

const transporter = nodemailer.createTransport({
  host: 'smtp.forwardemail.net',
  port: 465,
  secure: true,
  auth: {
    // TODO: Replace `user` and `pass` values from <https://forwardemail.net>
    user: 'REPLACE-WITH-YOUR-ALIAS@YOURDOMAIN.COM',
    pass: 'REPLACE-WITH-YOUR-GENERATED-PASSWORD',
  },
});

async function main() {
  const info = await transporter.sendMail({
    from: '"Fred Foo 👻" <foo@example.com>', // Sender address
    to: 'bar@example.com, baz@example.com', // List of receivers
    subject: 'Hello ✔', // Subject line
    text: 'Hello world?', // Plain text body
    html: `${emailFormatter.bold('Hello world?')}\

n${HTMLTags.heading1(
      'Hello world!',
      'text-align: center',
      'display: flex',
      'justify-contents: center',
      'align-items: center'
    )}`, // HTML body with formatted text and basic styles
  });

  console.log('Message sent: %s', info.messageId);
  // Output: Message sent: <b658f8ca-6296-ccf4-8306-87d57a0b4321@example.com>

  //
  // NOTE: You can go to https://forwardemail.net/my-account/emails to see the delivery status and preview of your email.
  //       Alternatively, you can use the "preview-email" npm package to preview emails locally in browsers and iOS Simulator.
  //       Check out the repository at <https://github.com/forwardemail/preview-email>.
  //
}

main().catch(console.error);

Feel free to explore the Format-Mail module and unleash your creativity in formatting beautiful emails! 😊🎉

Keywords

FAQs

Package last updated on 26 Jun 2023

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