pochta-mjml

Testing MJML/HTML emails simplified. A serverless cli application solution for multiple integrations.

Usage no npm install needed!

<script type="module">
  import pochtaMjml from 'https://cdn.skypack.dev/pochta-mjml';
</script>

README

Pochta (почта)


Pochta

Testing MJML/HTML emails simplified

oclif Version Downloads/week License

Introduction

Pochta is an open source cli application to help developers send test emails. Conventionally you need an email client or some form of API integration. Pochta eliminates that need and helps enhance your email testing workflow.

Features

  • MJML support
  • Multiple email service providers
  • Multiple cdn integrations
  • Smart cache for image uploads
  • Contact management
  • Screenshots
  • build and export
  • Minify HTML

Getting started

Installation

$ npm i pochta-mjml -g 

Example Usage

Below are a few basic examples, run $ pochta help for more details.

Send an email:

$ pochta send 

Create a profile:

$ pochta profiles new 

Create an esp:

$ pochta esp new 

Create a contact:

$ pochta contacts new 

Create an image hosting provider:

$ pochta hosts new 

Take a screenshot:

$ pochta capture 

Take a screenshot (advanced example):

  • The example below will generate 320 and 800 pixel wide screenshots @3 device scale factor. The output will be in the pdf format.
$ pochta capture -w 320 -w 800 -d 3 -f pdf

Why Pochta?

If you are using MJML app you can use MailJet integration to test your emails. However, neither your local images get hosted on MailJet server, nor you get an option to embed images as inline attachments or get to host on your preferred CDN directly.

Of course, these limitations can be overcome by exporting html manually and/or updating image sources but, if your assets are constantly changing during the development, then this can be a tedious task.

If you don't have a MailJet account than you're probably relying on Outlook 2010's stationary feature. Outlook is notorious for changing html content and will mess up your layouts in unintended ways.

Pochta eliminates this limitations and you can have multiple CDN and ESP for your need. Additionally, you can build and export your email with a CDN provider for the e-blast distribution.

Pochta also has a built in capture feature which can take screenshots of your email for various devices widths and scale factors.

Below are some email and CDN service providers that are currently supported by Pochta:

Email Service Providers

  • SendGrid
  • MailJet
  • Amazon SES
  • Gmail
  • Microsoft Exchange

CDN

  • AWS S3
  • Cloudinary
  • ImageKit

Manual

Usage

$ npm install -g pochta-mjml
$ pochta COMMAND
running command...
$ pochta (-v|--version|version)
pochta-mjml/1.1.1 darwin-x64 node-v14.0.0
$ pochta --help [COMMAND]
USAGE
  $ pochta COMMAND
...

Commands

pochta build

Build html/mjml files and export content into a new directory

USAGE
  $ pochta build

OPTIONS
  -c, --cache=cache  Boolean flag to enable/disable upload cache

DESCRIPTION
  This command generates HTML by parsing MJML/HTML and hosting images to the dedicated cdn provider. If no host selected 
  then, either the images can be embedded as Base64 or can be exported to a directory related to the generated html 
  file.

  By default the cache is disabled, meaning on each usage of this command it will try to upload images to the preferred 
  cdn provider. If you want to enable cache use with --cache=true flag.

See code: src/commands/build.js

pochta capture

Capture html/mjml screenshot and save in various format (i.e. png, jpg, pdf)

USAGE
  $ pochta capture

OPTIONS
  -d, --dsf=dsf             [default: 1] Device Scale Factor. Specifies that the screenshot must be taken at a higher
                            DPI

  -f, --format=jpg|png|pdf  [default: png] Screenshot export format

  -q, --quality=quality     [default: 80] Screenshot quality. Eligible only for if the export format is jpg

  -w, --width=width         [default: 800] Width of the screenshot. If multiple flags are provided, the command will
                            export and save screenshots for each width

DESCRIPTION
  This command generates a screenshot of the email and saves it under captures directory. In order for this command to 
  work a Chrome browser must be installed on the machine. The default screenshot width is 800px and will export as a 
  PNG.

  The default width can be overwritten with the width flag. This command supports multiple widths and it is helpful if 
  you like to capture different sizes. This is extremely helpful for responsive emails or checking email behaviour on 
  multiple sizes.

  If the dfg (Device Scale Factor) flag is set, the screenshots will result as scaled without loosing the quality. Ideal 
  for mimicking mobile devices screenshots.

  Screenshot quality and formats can be changed respectively via quality and format flags.

  The screenshot(s) will overwrite any existing files of the same names.

See code: src/commands/capture.js

pochta clear ENTITY

Clears cached settings

USAGE
  $ pochta clear ENTITY

ARGUMENTS
  ENTITY  (cache) [default: cache] Entity you would like to clear

DESCRIPTION
  This command will delete all the settings stored in a local directory or globally.

  If argument cache is given, it will remove previous user selections and cdn upload cache stored for the current 
  directory.

See code: src/commands/clear.js

pochta connections ACTION

Create, Read, Update, Delete, Test and Sync connections

USAGE
  $ pochta connections ACTION

ARGUMENTS
  ACTION  (list|new) [default: list] Action for the command

DESCRIPTION
  A connection is a form of integration which enhances and/or aids existing functionalities of Pochta. Connections are 
  built for manipulating root setting or adding features which don't belong to Pochta's core functionalities.

  Currently, only Redmine (version 4.0+) connection is supported. Adding this connection will sync contacts and user 
  profile with your account.

See code: src/commands/connections.js

pochta contacts ACTION

Create, Read, Update and Delete contacts

USAGE
  $ pochta contacts ACTION

ARGUMENTS
  ACTION  (list|new) [default: list] Action for the command

DESCRIPTION
  A contact is a form of recipients for supporting multiselect functionality to fill TO or CC fields.

See code: src/commands/contacts.js

pochta esp ACTION

Create, Read, Update, Delete and Test ESP

USAGE
  $ pochta esp ACTION

ARGUMENTS
  ACTION  (list|new) [default: list] Action for the command

DESCRIPTION
  ESP or Email Service Providers are required to send out test emails. There are two types of ESP currently supported by 
  Pochta:
  1) SMTP
  2) API based

  Configurations need to be setup on their dedicated platforms in order to work with Pochta.

See code: src/commands/esp.js

pochta help [COMMAND]

display help for pochta

USAGE
  $ pochta help [COMMAND]

ARGUMENTS
  COMMAND  command to show help for

OPTIONS
  --all  see all commands in CLI

See code: @oclif/plugin-help

pochta hosts ACTION

Create, Read, Update, Delete and Test image hosting providers

USAGE
  $ pochta hosts ACTION

ARGUMENTS
  ACTION  (list|new) [default: list] Action for the command

DESCRIPTION
  Configure your CDN provider with Pochta using this command. APIs needs to be enabled on the dedicated platforms in 
  order to work with Pochta.

See code: src/commands/hosts.js

pochta profiles ACTION

Create, Read, Update and Delete profiles

USAGE
  $ pochta profiles ACTION

ARGUMENTS
  ACTION  (list|new) [default: list] Action for the command

DESCRIPTION
  A profile is a contact which is displayed as an identification when sending out emails. This helps enable 
  functionalities to auto include as cc or reply to.

See code: src/commands/profiles.js

pochta send

Build, export and send HTML/MJML files as test emails with attachments

USAGE
  $ pochta send

OPTIONS
  -c, --cache=cache  Boolean flag to enable/disable upload cache

DESCRIPTION
  This command will provide a guide and selection process for sending out test emails. You can add additional 
  attachments from the current directory with the email.

  Subject line is derived from html's <title> tag. If the tag is missing Pochta will set a default value.

  An Image hosting provider is not necessary since Pochta can embed images inline or as attachments.

  Currently supported attachment types are: 'jpg', 'jpeg', 'png', 'webp', 'gif', 'svg', 'pdf', 'mp4', 'webm', 'mov', 
  'zip', 'txt'

See code: src/commands/send.js