Documentation Tutorials

Mail

import {
  htmlMail,
  plainMail
} from 'js-web'

Mail functions:

const web = require('js-web')
htmlMail(to,subject,htmlFile,templateContext)
plainMail(to,subject,text)

Setup

To get the mail working, you have to fill the .envfile mail section. The section’s default is setup to Gmail, so if you use Gmail as stmp provider, you can write your email and password. This way it will work

mail_host=smtp.gmail.com
mail_port=587
mail_ssl=false
mail_user=name@gmail.com
mail_password=mypassword
mail_from=

Plain mail

const web = require('js-web')
const emailBody = 'Hello, this is the email body'
plainMail('person@gmail.com','email from js-web',emailBody)

Html mail

The html mail is using a html file as an email bod, its using the same templating as the htmlRoute() function. You can read more about templating here.

const web = require('js-web')
htmlMail(
  'person@gmail.com',
  'email from js-web',
  'html/mail/welcome.html',
  {name: 'Simon'}
)

html/mail/welcome.html

Welcome: {{name}}