smtp

Generated by tinox doc

SMTP client (RFC 5321) for sending plain-text email: plaintext connect + STARTTLS (port 587), implicit TLS (port 465), SASL PLAIN auth. Typical use: password-reset and signup-confirmation emails.

ModuleVersionGroup
base641.0.0tinox.core
socket1.0.0tinox.core

Send email

import tinox.core.smtp;

class Main
{
    fnc main() -> Int32
    {
        let client: SmtpClient = SmtpClient::connect("smtp.example.org", 587);
        if client.conn <= 0
        {
            println("connect failed: " + client.errorMessage);
            return 1;
        }

        if !client.startTls()
        {
            println("STARTTLS failed");
            return 1;
        }

        if !client.authPlain("user", "pass")
        {
            println("auth failed");
            return 1;
        }

        client.send("me@example.org", ["you@example.org"], "Hi", "Hello from Tinox!");
        client.close();
        return 0;
    }
}

fn httpConnReadLine(conn: Int64) → String

fn httpConnTakeFd(conn: Int64) → Int64

class SmtpClient

Fields

connInt64
hostString
errorMessageString

Methods

fn connect(host: String, port: Int64) → SmtpClient
fn connectTls(host: String, port: Int64, verify: Bool) → SmtpClient
fn finishConnect(conn: Int64, host: String) → SmtpClient
fn ehlo() → Bool
fn startTls() → Bool
fn authPlain(user: String, pass: String) → Bool
fn send(from: String, to: List<String>, subject: String, body: String) → Bool
fn close() → Nothing
fn readReply(conn: Int64) → String