adonis-mailbuilder
TypeScript icon, indicating that this package has built-in type declarations

2.2.1 • Public • Published

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:

npm i --save adonis-mailbuilder

Connect all dependences:

node ace configure adonis-mailbuilder

Create yor first mail

node ace mailbuilder:make AnyName

Start dev server

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

import MailBuilder from '@ioc:Adonis/Addons/MailBuilder'
import AnyName from 'App/MailBuilder/AnyName'
import Mail from '@ioc:Adonis/Addons/Mail'
import Env from '@ioc:Adonis/Core/Env'
export default class AuthController {
  public async register ({ auth, request, response }: HttpContextContract) {
    const { text, html } = await MailBuilder.render(
      new AnyName({ name: 'AnyName' })
    )
    await Mail.send(mail => {
        mail.subject('Thanks for registering')
        mail.text(text)
        mail.html(html)
        mail.to(ctx.session.email)
        mail.from(Env.get('MAIL_FROM') as string)
    })
  }
}

Docs for mailbuilder configuration

See docs

Readme

Keywords

Package Sidebar

Install

npm i adonis-mailbuilder

Weekly Downloads

3

Version

2.2.1

License

MIT

Unpacked Size

24.9 kB

Total Files

21

Last publish

Collaborators

  • beatlelab