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: {
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>',
to: 'bar@example.com, baz@example.com',
subject: 'Hello ✔',
text: 'Hello world?',
html: `${emailFormatter.bold('Hello world?')}\n${HTMLTags.heading1(
'Hello world!',
'text-align: center',
'display: flex',
'justify-contents: center',
'align-items: center'
)}`,
});
console.log('Message sent: %s', info.messageId);
}
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: {
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>',
to: 'bar@example.com, baz@example.com',
subject: 'Hello ✔',
text: 'Hello world?',
html: `${emailFormatter.bold('Hello world?')}\
n${HTMLTags.heading1(
'Hello world!',
'text-align: center',
'display: flex',
'justify-contents: center',
'align-items: center'
)}`,
});
console.log('Message sent: %s', info.messageId);
}
main().catch(console.error);
Feel free to explore the Format-Mail module and unleash your creativity in formatting beautiful emails! 😊🎉