Skip to content

Latest commit

 

History

History
71 lines (48 loc) · 1.48 KB

File metadata and controls

71 lines (48 loc) · 1.48 KB

SMTP ThingsDB Module (Go)

SMTP module written using the Go language.

Installation

Install the module by running the following command in the @thingsdb scope:

new_module("smtp", "github.com/thingsdb/module-go-smtp");

Optionally, you can choose a specific version by adding a @ followed with the release tag. For example: @v0.1.0.

Configuration

The smtp module requires configuration with the following properties:

Property Type Description
host str (required) SMTP host, eg 'myhost.local:587'
auth [str, str] Optional authentication. [Username, Password].

Example configuration:

set_module_conf("smtp", {
    host: "myhost.local:587",
    auth: ["myuser", "mypassword"],
});

Exposed functions

Name Description
send_mail Send an email.

Send mail

Syntax: send_mail(to, mail)

Arguments

  • mail: (thing) Mail to send.

Example:

// Only subject is required
mail = {
    bcc: ['charlie@foo.bar'],
    cc: ['info@foo.bar'],
    from: 'bob@foo.bar',
    from_name: 'Bob',
    html: '<html>Html Body</html>',
    plain: 'plain text body',
    reply_to: 'bob@foo.bar',
    subject: 'my subject',
};

to = ['alice@foo.bar'];

// Send the email
smtp.send_mail(to, mail).else(|err| {
    err;  // some error has occurred
})