Module std::net::smtp

SMTP client for sending email.

Provides functions for connecting to an SMTP server and sending plain-text or HTML email messages.

Examples

import std::net::smtp;

fn main() {
    let conn = smtp.connect_tls("smtp.example.com", 587, "user", "pass");
    conn.send("from@example.com", "to@example.com", "Subject", "Body");
    conn.close();
}

Contents

Functions

Function connect

pub fn connect(host: String, port: i32, username: String, password: String) -> Conn

Connect to an SMTP server without TLS.

Examples

let conn = smtp.connect("localhost", 25, "", "");

Function connect_tls

pub fn connect_tls(host: String, port: i32, username: String, password: String) -> Conn

Connect to an SMTP server with TLS encryption.

Examples

let conn = smtp.connect_tls("smtp.example.com", 587, "user", "pass");

Types

Struct Conn

An open SMTP connection handle.

Created by calling smtp.connect(...) or smtp.connect_tls(...). Use send() or send_html() to deliver messages.

Traits

Trait ConnMethods

Methods available on an SMTP Conn.

Methods

fn send(self: Conn, from: String, to: String, subject: String, body: String) -> i32 fn send_html(self: Conn, from: String, to: String, subject: String, html: String) -> i32 fn close(self: Conn)