Categorygithub.com/thingsdb/module-go-smtp
modulepackage
0.1.4
Repository: https://github.com/thingsdb/module-go-smtp.git
Documentation: pkg.go.dev

# README

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:

PropertyTypeDescription
hoststr (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

NameDescription
send_mailSend an email.

Send mail

Syntax: send_mail(to, mail)

Arguments

  • mail: (thing) Mail to send.

Example:

// Only subject is required
mail = {
    bcc: ['[email protected]'],
    cc: ['[email protected]'],
    from: '[email protected]',
    from_name: 'Bob',
    html: '<html>Html Body</html>',
    plain: 'plain text body',
    reply_to: '[email protected]',
    subject: 'my subject',
};

to = ['[email protected]'];

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