Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zaikoxander/xander-email
xander-email is a library to facilitate the use of nodemailer
https://github.com/zaikoxander/xander-email
components email html javascript javascript-library nodejs nodemailer nodemailer-plugin typed types typescript typescript-definitions typescript-library variables views
Last synced: 23 days ago
JSON representation
xander-email is a library to facilitate the use of nodemailer
- Host: GitHub
- URL: https://github.com/zaikoxander/xander-email
- Owner: ZaikoXander
- License: mit
- Created: 2022-08-26T03:16:23.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-09-01T16:39:43.000Z (over 2 years ago)
- Last Synced: 2024-10-16T05:31:16.780Z (3 months ago)
- Topics: components, email, html, javascript, javascript-library, nodejs, nodemailer, nodemailer-plugin, typed, types, typescript, typescript-definitions, typescript-library, variables, views
- Language: JavaScript
- Homepage:
- Size: 25.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# xander-email
A library to facilitate the use of nodemailer.[![npm](https://img.shields.io/npm/v/xander-email)](https://www.npmjs.com/package/xander-email)
[![GitHub](https://img.shields.io/github/license/ZaikoXander/xander-email)](LICENSE)## Installation
You may install this module using npm or Yarn.
```bash
npm i xander-email
```
Or ``yarn add xander-email`` for Yarn## How to use
```js
import xanderEmail from "xander-email"transport.sendMail({
from: "Support ",
to: "Client ",
subject: "Test",
html: xanderEmail("view1", "./src/modules/mailer/views", { title: "xander-email" })
})
```### Views
Assuming that you already know how to use ``nodemailer``, start creating a folder for the email's views.
This views is basically web pages (html), so you just need to create elements like this:
```html
Document
{{title}}
{{greenBox}}
```
### Components
You probably notice that this two lines are not html elements.
So... What is it?```html
{{title}}
{{greenBox}}
```Well, those are components, which can be called from multiple different ``Views``.
And in reality to take an example, here we have the ``title`` component:
```html
{{-title}}
```### Variables
There are variables too, we will take a look how to use them later.
```html
{{-title}}
```### Finally getting our views using xander-email
Before, you need to make sure that the ``components`` folder is inside the ``views`` folder. Just like this:
And the name of the ``components`` folder needs to be in lowercase (for now).Now we just need to create the transport of nodemailer, and when sending the Email, write on the html param something like:
```js
import xanderEmail from "xander-email"transport.sendMail({
from: "Support ",
to: "Client ",
subject: "Test",
html: xanderEmail("body", "./src/modules/mailer/views", { title: "xander-email" }) // <--
})
```
#### Params
* viewName(the name of the view file that you want)
* viewsPath(the path to your views folder, and it includes the view folder itself)
* variables(an object that receives keys (name of the variables of the views) and the values of it)