JSPM

  • Created
  • Published
  • Downloads 2
  • Score
    100M100P100Q82423F
  • License MIT

KohanaJS Transactional Email Module

Package Exports

  • @kohanajs/mod-mail
  • @kohanajs/mod-mail/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@kohanajs/mod-mail) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

kohanajs-mod-mail

Module for Transactional email

##install npm i @kohanajs/mod-mail

this will install Mail Object with default adapter for preview

add require("@kohanajs/mod-mail"); to application/require.js to load default config file and default routes.

##usage

const {Mail} = require('@kohanajs/mod-mail');

const mail = new Mail({
  domain:'localhost',
  ip:'127.0.0.1'
});
await mail.send('this is subject', 'this is body text', 'sender@kohanajs.com', 'recipient@example.com')

###templates

const mail = new Mail({
  domain:'localhost',
  ip:'127.0.0.1'
  templateFolder: `${__dirname}/edm`
});

const result = await mail.send('subject', 'test.txt', 'TEST', '20221234', {
  html:'test.html',
  tokens: {'message': 'hello world'},
});

//result.payload.text
//result.payload.html

###only html template

const mail = new Mail({
  domain:'localhost',
  ip:'127.0.0.1'
  templateFolder: new Map([
    ['html', `${__dirname}/edm`]
  ])
});

const result = await mail.send('subject', 'hello {{@message}}', 'TEST', '20221234', {
  html:'test.html',
  tokens: {'message': 'hello world'},
});

//result.payload.text
//result.payload.html

###template use handle (WIP)

const mail = new Mail({
  domain:'localhost',
  ip:'127.0.0.1'
  templateFolder: '@edm'
});

const result = await mail.send('subject', 'test::text', 'TEST', '20221234', {
  html:'test::html',
  tokens: {'message': 'hello world'},
});