vite-email v0.8.3
vite-email
Send emails rendered by Vite and Markdown-It automatically.
Features
- 📝 Render Markdown email template using csv table data
- 🔥 Emails dev server with HMR support powered by Vite
- 📧 Automatically send emails
Installation
npm i -D vite-emailYou can also install it globally.
npm i -g vite-email
vmail --versionUsage
Create a new workspace.
vmail init new-workspace
cd new-workspace
npm installThe created workspace contains some config files. data.csv stores the list of receivers and corresponding information. The receiver column specify the email of the receiver. email.md is the email content template to be rendered. You can use {{ ... }} to insert variable from data.csv.
For example, here is data.csv.
receiver, name
bot@github.com, BotHere is email.md.
# Hello {{ name }}Then, you can start a dev server to preview the content of emails, or preview the render output with the option --dry-run.
vmail dev
# or
vmail send --dry-runIf everything is done, send emails with a simple command. This command may prompt you to type the sender email address and its password.
vmail sendThe email template will be rendered to HTML using the csv data, and be sent to the receiver email. In this example, the following content will be send to bot@github.com.
<h1>Hello Bot</h1>Configuration
Just modify the vite.config.ts.
// vite.config.ts
import { defineConfig } from 'vite-email';
export default defineConfig({
email: {
host: 'smtp.yeah.net',
secure: true,
auth: {
user: 'yan_jl@yeah.net',
// pass: '...', // vmail will prompt if pass is empty
},
frontmatter: {
receiver({ name }) {
return `${name}@users.noreply.github.com`
},
today: new Date().toLocaleDateString(),
author: 'XLor'
}
}
});You can find this example here.
License
MIT License © 2022 XLor