Generic SMTP plugin for Publiqate
Clone this repository. Navigate to the plugins -> smtp
folder and run:
npm run build
Once the build process is complete the compiled code will be available in plugins -> smtp -> dist
folder.
Copy the content of the dist
folder somewhere on the server, where Publiqate
is running and specify the location from where Publiqate
will load the plugin.
Once the config is set either restart the Publiqate
service or visit the admin UI and press "Refresh config".
Example config:
...
plugins:
- c:\path\to\smtp\plugin\dist\index.js
...
notifications:
- type: Stream
...
callbacks:
- type: mail
details:
host: some-host-or-ip
port: 123
from: test@test-company.com
to:
- recipient1@test-company.com
- recipient2@test-company.com
subject: "Stream updated"
# html: <h1>Stream updated</h1><br><div>Stream has been updated</div>
template: c:\path\to\template.ejs # see Templates section for details
engine: handlebars # or ejs, pug, mustache
auth:
user: some-user
pass: secret-password
...
-
host
- SMTP server host/ip -
port
- SMTP server port -
secure
- optional. boolean. Default istrue
-
proxy
- optional. TCP proxy -
from
- email address from which the emails will be send -
to
- array of emails -
subject
- email subject -
html
- HTML string to be used as the mail body. Ifhtml
andtemplate
are present then onlytemplate
is used -
template
- full path to the EJS template to use (seeTemplates
section for details) -
headers
- optional. List of additional headers (header-name: header-value
) -
auth
- seeAuthentication
section
Three authentication methods are supported:
Very basic one. Provide user
and pass
properties
-
user
- user email address -
clientId
- the registered client id of the application -
clientSecret
- the registered client secret of the application -
refreshToken
- optional. If it is provided then tries to generate a new access token if existing one expires or fails -
accessToken
- he access token for the user. Required only if refreshToken is not available -
expires
- optional. expiration time for the current accessToken -
accessUrl
- optional. HTTP endpoint for requesting new access tokens. This value defaults to Gmail
For more information have a look at 3-legged OAuth2 authentication
-
user
- user email address you want to send mail as -
serviceClient
- service client id. Found it in the service key file (client_id
field) -
privateKey
- private key content. Found it in the service key file (private_key
field)
For more information have a look at 2LO authentication (service accounts)
The plugin support 4 template engines:
- ejs
- handlebars - default
- pug
- mustache
For each template engine error log entry will be generated if the template fails to compile/render.
Examples how to render list of names for all entities in the notification for each template engine:
<ul><% entities.forEach((entity,index) => {%>
<li><%= entity.details.name %></li><% }) %>
</ul>
ul
each n in entities
li= n.details.name
<ul>
{{#entities}}
<li>{{details.name}}</li>
{{/entities}}
</ul>