Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/yjl9903/vite-email
Send emails rendered by Vite and Markdown-It automatically
https://github.com/yjl9903/vite-email
email-sender markdown vite
Last synced: 7 days ago
JSON representation
Send emails rendered by Vite and Markdown-It automatically
- Host: GitHub
- URL: https://github.com/yjl9903/vite-email
- Owner: yjl9903
- License: mit
- Created: 2022-03-23T11:53:35.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-02-11T15:24:59.000Z (almost 2 years ago)
- Last Synced: 2024-10-12T04:51:57.630Z (about 1 month ago)
- Topics: email-sender, markdown, vite
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/vite-email
- Size: 546 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# vite-email
[![version](https://img.shields.io/npm/v/vite-email?color=rgb%2850%2C203%2C86%29&label=vite-email)](https://www.npmjs.com/package/vite-email) [![CI](https://github.com/yjl9903/vite-email/actions/workflows/ci.yml/badge.svg)](https://github.com/yjl9903/vite-email/actions/workflows/ci.yml)
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](https://vitejs.dev/)
+ 📧 Automatically send emails## Installation
```bash
npm i -D vite-email
```You can also install it globally.
```bash
npm i -g vite-email
vmail --version
```## Usage
Create a new workspace.
```bash
vmail init new-workspace
cd new-workspace
npm install
```The 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`.
```csv
receiver, name
[email protected], Bot
```Here is `email.md`.
```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`.
```bash
vmail dev
# or
vmail send --dry-run
```If everything is done, send emails with a simple command. This command may prompt you to type the sender email address and its password.
```bash
vmail send
```The 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 `[email protected]`.
```html
Hello Bot
```### Configuration
Just modify the `vite.config.ts`.
```ts
// vite.config.tsimport { defineConfig } from 'vite-email';
export default defineConfig({
email: {
host: 'smtp.yeah.net',
secure: true,
auth: {
user: '[email protected]',
// 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](https://github.com/yjl9903/vite-email/tree/main/example).
## License
MIT License © 2022 [XLor](https://github.com/yjl9903)