Email Source Integration

An email source represents an SMTP server with the express goal of sending messages to email accounts using an SMTP server. An email source ONLY supports publishing notifications.

Define an Email Source

An Email source may be created from the “Sources” page in the Developer Portal. (Select the “Rules” / “Source” menu item.) Simply click the “Create Source” button and enter the required information:

Once registered the Email source will immediately be available to publish notifications as email messages.

An Email source may also be defined using the command-line interface by creating a JSON object of type ArsSource that represents the definition of the remote source and submitting the definition to Vantiq for registration.

The relevant ArsSource properties are as follows:

Create EMAIL Source

POST https://dev.vantiq.com/api/v1/resources/sources
{ 
    "name": "MyEmailServer",
    "type": "EMAIL",
    "direction": "SINK",
    "config": {
       "host": "mail.domain.com",
       "port": 587,
       "username": "vantiq",
       "password": "vantiq"
    }
}

Creates an EMAIL source with the smtp server at the URI specified.

Delete EMAIL Source

POST https://dev.vantiq.com/api/v1/resources/sources/MyEmailServer

Deletes the email source created in the previous example.

Publish Notifications via Email Service

Notifications are produced by the rules system when PUBLISH is called as a rule action. The PUBLISH request for EMAIL sources takes three parameters: the source to which the publish is sent, the body of the email, and the publish parameters object. The EMAIL source will deliver the notifications to the specified receivers via the configured SMTP server.

The message is a JSON object containing the following properties:

Only one of text and html should be used.

The publish parameters object must have the following properties:

For example, inside your rule you could use a line like this to send an email message:

PUBLISH { text: "The body of the message." } TO SOURCE MyEmailSource 
  USING { from: "me@mydomain.com", 
            to: [ "user1@domain.com", "user2@domain.com" ],
       subject: "The subject line" }