Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rewrking/nodemailer-mjml-sender
Node.js based emailer
https://github.com/rewrking/nodemailer-mjml-sender
email mjml nodejs nodemailer typescript
Last synced: 10 days ago
JSON representation
Node.js based emailer
- Host: GitHub
- URL: https://github.com/rewrking/nodemailer-mjml-sender
- Owner: rewrking
- License: mit
- Created: 2019-05-29T01:51:29.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2024-01-26T20:05:21.000Z (11 months ago)
- Last Synced: 2024-08-09T21:10:15.391Z (5 months ago)
- Topics: email, mjml, nodejs, nodemailer, typescript
- Language: TypeScript
- Homepage:
- Size: 127 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# nodemailer-mjml-sender
"EmailSender" wrapper class around nodemailer & MJML. Simply read from an mjml file, setup the transporter & sender, and voila!
The MJML template can take basic handlebars-style variables like `{{ variable }}`.
Example usage:
```typescript
import path from "path";
import { EmailSender } from "nodemailer-mjml-wrapper";async function sendEmail() {
const mailer = new EmailSender();
mailer.transporter
.host("smtp.gmail.com")
.secure(true)
.account({
user: "...",
pass: "..."
});const templatePath = path.join(process.cwd(), "templates");
mailer.sender
.from({
name: "John Doe",
email: "[email protected]"
})
.to(["[email protected]"])
.subject("You have an email!")
.template(path.join(templatePath, "email-template.mjml"), {
variable: "Here is some dynamic variable that needs to be replaced",
});const result = await mailer.send();
console.log("Email sent:", result.messageId);
}
```See the repository's test folder for a more complete example.
---
Use for good, comply with the CAN-SPAM Act, etc.