Class: Emailer

arpen/services/emailer~ Emailer

Emailer

emailjs module is required

Add to your config:
// SMTP servers
smtp: {
  main: {
    host: 'localhost',
    port: 25,
    ssl: false,
    //user: 'username',
    //password: 'password',
  },
},

email: {
  from: 'root@localhost',
  log: {
    enable: false,                  // email logger messages or not
    level: 'error',
    to: 'debug@example.com',
  },
  crash: {
    enable: false,                  // email program crash when using ./bin/daemon
    to: 'debug@example.com',
  },
}

new Emailer(config)

Create the service
Parameters:
Name Type Description
config object Configuration

Members


<static> provides :string

Service name is 'emailer'
Type:
  • string

<static> requires :Array.<string>

Dependencies as constructor arguments
Type:
  • Array.<string>

Methods


<async> send(params)

Send email
Parameters:
Name Type Description
params object Parameters
Properties
Name Type Argument Description
server string <optional>
SMTP server name (as in config)
from string From address
to string To address
cc string <optional>
CC address
subject string The subject
text string <optional>
Plain text variant of the message
html string <optional>
Html variant of the message
attachments Array.<object> <optional>
Array of objects (see emailjs help)
Returns:
Resolves to the sent message details
Type
Promise

_connect(server)

Create connection instance
Parameters:
Name Type Default Description
server string 'main' SMTP server name
Returns:
Returns emailjs instance
Type
object