module-go-smtp

command module
v0.1.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 12, 2024 License: MIT Imports: 8 Imported by: 0

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:

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
})

Documentation

Overview

ThingsDB module for sending emails using SMTP.

For example:

// Create the module (@thingsdb scope)
new_module('smtp', 'github.com/thingsdb/module-go-smtp');

// Configure the module
set_module_conf('smtp', {
    host: 'my-smtp-host:587",
    auth: ['my-optional-user', 'my-optional-password'],
});

// Use the module
smptp.send_mail(["alice@foo.bar"], {
    from: "bob@foo.bar",
    subject: "my subject",
    plain: "my body",
}).else(|err| {
    // error handling....
}));

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL