项目作者: reg2005

项目描述 :
AdonisJS 5 simple mailbuilder with livereload
高级语言: TypeScript
项目地址: git://github.com/reg2005/adonis-mailbuilder.git
创建时间: 2020-07-10T08:08:24Z
项目社区:https://github.com/reg2005/adonis-mailbuilder

开源协议:MIT License

下载


Table of contents

AdonisJS 5 mailbuilder

Adonis, mailbuilder, mailgen, livereloading

travis-image typescript-image npm-image license-image

How it works

  • Declarative creation of mails in classes (based on mailgen)
  • Livereload as CLI command (for quickly devloping your emails)
  • Mock data for tests (so that letters developed through livereload correspond to real letters that will go to the mail)
  • Naturally everywhere Typescript is used
  • CLI command to quickly create a Mailbuilder class based on the principle of “node ace make:model ModelName”

Installation

Install it:

  1. npm i --save adonis-mailbuilder

Connect all dependences:

  1. node ace configure adonis-mailbuilder

Create yor first mail

  1. node ace mailbuilder:make AnyName

Start dev server

  1. npm run dev

Go to url from cli like ‘http://localhost:3333/mailbuilder

Go to app/MailBuilder/AnyName.ts and change any options

Send your email

  1. import MailBuilder from '@ioc:Adonis/Addons/MailBuilder'
  2. import AnyName from 'App/MailBuilder/AnyName'
  3. import Mail from '@ioc:Adonis/Addons/Mail'
  4. import Env from '@ioc:Adonis/Core/Env'
  5. export default class AuthController {
  6. public async register ({ auth, request, response }: HttpContextContract) {
  7. const { text, html } = await MailBuilder.render(
  8. new AnyName({ name: 'AnyName' })
  9. )
  10. await Mail.send(mail => {
  11. mail.subject('Thanks for registering')
  12. mail.text(text)
  13. mail.html(html)
  14. mail.to(ctx.session.email)
  15. mail.from(Env.get('MAIL_FROM') as string)
  16. })
  17. }
  18. }

Docs for mailbuilder configuration

See docs