This driver is used to send email by connecting to the SMTP server. The driver is using the following SMTP library : https://nodemailer.com/about/
Gateway parameters
The gateway parameters are defined in the gateway json (refer to core/gateways module). Those are passed directly to the nodemailer nodemailer.createTransport function (refer to https://nodemailer.com/about/).
Address format
The address name is the standard the email address with optional additional "from" and "subject". The information between brackets is optional: [from]:to:[subject]. It is possible to have multiple destinations by seperating the emails addresses with comma. The body of the sent email is the value written on the address. Here are some valid examples for the address
Use cases
The use of the SMTP driver is only to send emails from the system. In order to receive emails, another driver should be integrated (e.g. imap / pop3 client). Note that if the email address does not exist yet in the system, it will be added automatically.
Gateway parameters
The gateway parameters are defined in the gateway json (refer to core/gateways module). Those are passed directly to the nodemailer nodemailer.createTransport function (refer to https://nodemailer.com/about/).
{
"id" : 1,
"name" : "SMTP client",
"description" : "...",
"activ" : 1,
"driver": "smtp", // is linked to driver code (modbus.js) implementing the driver functions.
"json" : { // used to store driver parameters.
"smtp : {
host: 'smtp.example.com',
port: 465,
auth: {
user: 'username@example.com',
pass: 'userpass'
}
},
"defaultSubject" : 'home automation',
// Defines a default subject for mails if missing.
"defaultFrom" : 'username@example.com',
// SMTP allows multiple FROM addresses in the RFC.
// if only one address is used and the auth user is the email address,
// then it can be left empty.
"froms" : ['username@example.com', 'username2@example.com']
// froms is the list of addresses that may send emails.
// If only one address is used it can be left empty
},
"private_json" : {...} //can be used by anyone to store custom informations independent from the driver itself.
}
Address format
The address name is the standard the email address with optional additional "from" and "subject". The information between brackets is optional: [from]:to:[subject]. It is possible to have multiple destinations by seperating the emails addresses with comma. The body of the sent email is the value written on the address. Here are some valid examples for the address
- ehelfer@weble.ch would be used to send an email to ehelfer@weble.ch with default subject.
- ptorrent:ehelfer@weble.ch would be used to send an email to ehelfer@weble.ch with ptorrent@weble.ch as sender.
- ptorrent:ehelfer@weble.ch,artem@weble.ch would be used to send an email to ehelfer@weble.ch and artem@weble.ch with ptorrent@weble.ch as sender.
- ptorrent:ehelfer@weble.ch,artem@weble.ch:windAlert is the same as above, but defines also a custom subject (windAlert).
Use cases
The use of the SMTP driver is only to send emails from the system. In order to receive emails, another driver should be integrated (e.g. imap / pop3 client). Note that if the email address does not exist yet in the system, it will be added automatically.
//sends basic email with the default subject.
gateways.writeValue('ehelfer@weble.ch', 'this is the email body')
//sends email to multiple destination with custom email subject.
gateways.writeValue('ehelfer@weble.ch,artem@weble.ch:windAlert', 'The wind speed was recorded above 60 m/s at 17:16 the 7 of July')