@informatiqal/publiqate-smtp v1.0.0
Publiqate SMTP
Generic SMTP plugin for Publiqate
Build and Installation
Clone this repository. Navigate to the plugins -> smtp folder and run:
npm run buildOnce 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
...Options
host- SMTP server host/ipport- SMTP server portsecure- optional. boolean. Default istrueproxy- optional. TCP proxyfrom- email address from which the emails will be sendto- array of emailssubject- email subjecthtml- HTML string to be used as the mail body. Ifhtmlandtemplateare present then onlytemplateis usedtemplate- full path to the EJS template to use (seeTemplatessection for details)headers- optional. List of additional headers (header-name: header-value)auth- seeAuthenticationsection
Authentication
Three authentication methods are supported:
User and pass
Very basic one. Provide user and pass properties
3-legged legged OAuth
user- user email addressclientId- the registered client id of the applicationclientSecret- the registered client secret of the applicationrefreshToken- optional. If it is provided then tries to generate a new access token if existing one expires or failsaccessToken- he access token for the user. Required only if refreshToken is not availableexpires- optional. expiration time for the current accessTokenaccessUrl- optional. HTTP endpoint for requesting new access tokens. This value defaults to Gmail
For more information have a look at 3-legged OAuth2 authentication
2LO OAuth
user- user email address you want to send mail asserviceClient- service client id. Found it in the service key file (client_idfield)privateKey- private key content. Found it in the service key file (private_keyfield)
For more information have a look at 2LO authentication (service accounts)
Templates
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:
EJS
<ul><% entities.forEach((entity,index) => {%>
<li><%= entity.details.name %></li><% }) %>
</ul>Handlebars
<ul>
{{#each entities}}
<li>{{this.details.name}}</li>
{{/each}}
</ul>Pug
ul
each n in entities
li= n.details.nameMustache
<ul>
{{#entities}}
<li>{{details.name}}</li>
{{/entities}}
</ul>1 year ago