Adonis, mailbuilder, mailgen, livereloading
- 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"
Install it:
npm i --save adonis-mailbuilder
Connect all dependences:
node ace configure adonis-mailbuilder
node ace mailbuilder:make AnyName
npm run dev
Go to url from cli like 'http://localhost:3333/mailbuilder'
Go to app/MailBuilder/AnyName.ts and change any options
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)
})
}
}