All Projects → mat-sz → React Letter

mat-sz / React Letter

Licence: bsd-3-clause-clear
✉️ Display e-mails in your React.js projects. (Targets Gmail rendering.)

Programming Languages

javascript
184084 projects - #8 most used programming language
typescript
32286 projects

Projects that are alternatives of or similar to React Letter

Wmail
The missing desktop client for Gmail & Google Inbox
Stars: ✭ 2,093 (+1176.22%)
Mutual labels:  email, gmail
gnome-email-notifications
Gnome Email Notifications
Stars: ✭ 65 (-60.37%)
Mutual labels:  email, gmail
Forwardemail.net
The best free email forwarding for custom domains (Web Server)
Stars: ✭ 211 (+28.66%)
Mutual labels:  email, gmail
Free Email Forwarding
The best free email forwarding for custom domains. Visit our website to get started (SMTP server)
Stars: ✭ 2,024 (+1134.15%)
Mutual labels:  email, gmail
Gatsby Mail
A Gatsby email *application*
Stars: ✭ 450 (+174.39%)
Mutual labels:  email, gmail
Clojure Mail
A Clojure library for parsing, downloading and reading email from IMAP servers.
Stars: ✭ 172 (+4.88%)
Mutual labels:  email, gmail
gmail-gitlab-filtering
Google Apps Script for Gmail to filter and sort email from GitLab
Stars: ✭ 84 (-48.78%)
Mutual labels:  email, gmail
emailpyspam
A python 3+ program to spam emails to a list of users repetitively
Stars: ✭ 63 (-61.59%)
Mutual labels:  email, gmail
Gmail Desktop
📮 Nifty Gmail desktop app for macOS, Linux & Windows
Stars: ✭ 317 (+93.29%)
Mutual labels:  email, gmail
Lieer
Fast email-fetching and sending and two-way tag synchronization between notmuch and GMail
Stars: ✭ 301 (+83.54%)
Mutual labels:  email, gmail
Magento2 Gmail Smtp App
Configure Magento 2 to send email using Google App, Gmail, Amazon Simple Email Service (SES), Microsoft Office365 and many other SMTP (Simple Mail Transfer Protocol) servers
Stars: ✭ 281 (+71.34%)
Mutual labels:  email, gmail
Waveboxapp
Wavebox Classic has been updated to Wavebox 10. Learn more Wavebox.io
Stars: ✭ 1,198 (+630.49%)
Mutual labels:  email, gmail
Imapcopy
Recursively copy all e-mail messages and folders from one IMAP account to another.
Stars: ✭ 52 (-68.29%)
Mutual labels:  email, gmail
Correo
💌 A menubar/taskbar Gmail App for Windows and macOS
Stars: ✭ 119 (-27.44%)
Mutual labels:  email, gmail
Mag.js
MagJS - Modular Application Glue
Stars: ✭ 157 (-4.27%)
Mutual labels:  javascript-library
Dart Basic Utils
A dart package for many helper methods fitting common situations
Stars: ✭ 153 (-6.71%)
Mutual labels:  email
Nanolist
mailing lists - the unix way
Stars: ✭ 153 (-6.71%)
Mutual labels:  email
Email Verifier
✅ A Go library for email verification without sending any emails.
Stars: ✭ 162 (-1.22%)
Mutual labels:  email
Mjml
MJML: the only framework that makes responsive-email easy
Stars: ✭ 12,880 (+7753.66%)
Mutual labels:  email
Papercut Smtp
Papercut SMTP -- The Simple Desktop Email Server
Stars: ✭ 2,094 (+1176.83%)
Mutual labels:  email

react-letter

workflow npm npm NPM

react-letter is a React.js component that allows for an easy display of HTML e-mail content with automatic sanitization. Support for features should match what is supported by Gmail.

Features:

  • <style> support.
  • Automatic removal of relative URLs.
  • Support for rewriting the link and resource URLs to increase user's privacy and security.
  • Prefixing classes and IDs to prevent clashing with page styles.
  • Wrapping contents in an iframe (as an option).
  • First-class TypeScript support (the entire library is written in TypeScript), along with a related RFC 822 parser project also written in TypeScript.
  • No dependencies except for React itself.

The component itself is parser-agnostic, and can be used with any RFC 822 parser as long as it provides HTML or text output. The sanitization is done on the client-side using DOMParser with some security features targeting older browsers (although there's no guarantee of full functionality under browser versions older than 5 years).

Check other TypeScript e-mail projects:

Parser Inbound SMTP
letterparser microMTA

Installation

react-letter is available on NPM, and can be installed with either npm or yarn:

yarn add react-letter

A Vue.js version is also available: vue-letter.

Usage

See: Example or play in the CodeSandbox.

react-letter can be used with letterparser (currently in development, but it's the only RFC 822 parser with browser support as far as I know) or any other parser like this:

import { Letter } from 'react-letter';
import { extract } from 'letterparser';

const { html, text } = extract(`Date: Wed, 01 Apr 2020 00:00:00 -0000
From: A <[email protected]>
To: B <[email protected]>
Subject: Hello world!
Mime-Version: 1.0
Content-Type: text/html; charset=utf-8

Some message.`);

// No sanitization needs to be performed beforehand,
// react-letter takes care of sanitizing the input.
<Letter html={html} text={text} />;

sanitize function

react-letter also exposes a sanitize function that uses DOMParser to sanitize the HTML content of messages and returns HTML text. This allows for usage in other libraries without having to copy the code from react-letter.

interface SanitizerOptions {
  id?: string;
  dropAllHtmlTags?: boolean;
  rewriteExternalResources?: (url: string) => string;
  rewriteExternalLinks?: (url: string) => string;
  allowedSchemas?: string[];
  preserveCssPriority?: boolean;
  noWrapper?: boolean;
}

function sanitize(html: string, text?: string, options?: SanitizerOptions);

Configuration

Letter supports the following properties:

useIframe?: boolean;

Should the HTML be wrapped in an iframe. Default: false.

iframeTitle?: string;

Iframe title, usually set to subject of the message.

rewriteExternalResources?: (url: string) => string;

The result of this function will be used to rewrite the URLs for url(...) in CSS and src attributes in HTML.

rewriteExternalLinks?: (url: string) => string;

The result of this function will be used to rewrite the URLs for href attributes in HTML.

allowedSchemas?: string[];

List of allowed URL schemas. Default: ['http', 'https', 'mailto'].

preserveCssPriority?: boolean;

Preserves CSS priority (!important), default: true.

className?: string;

Class name of the wrapper div.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].