XU XUv0.8.8
中文

API

#github.com/xulang-org/packages/smtp

import: smtp #github.com/xulang-org/packages/smtp

counts: 5 fns, 7 methods, 4 types, 0 consts, 0 ifaces

External package `smtp #github.com/xulang-org/packages/smtp`, provided by github.com/xulang-org/packages.

github.com/xulang-org/packages · 0.1.1 · Install and use

client

XuAPI
pub fn client(endpoint string) SmtpClient

Purpose

client; returns SmtpClient.

Parameters

endpoint string
endpoint (string)

Returns

SmtpClient — a value of this type

pool

XuAPI
pub fn pool(endpoint string, max_conns int) SmtpPool

Purpose

pool; returns SmtpPool.

Parameters

endpoint string
endpoint (string)
max_conns int
max_conns (int)

Returns

SmtpPool — a value of this type

struct Message

XuAPI
pub struct Message {
    pub from string
    pub to string
    pub subject string
    pub body string
}

Purpose

Public struct `Message`.

Parameters

from string
field (string)
to string
field (string)
subject string
field (string)
body string
body

struct SmtpClient

XuAPI
pub struct SmtpClient {
    pub host string
    pub port int
    pub username string
    pub password string
}

Purpose

Public struct `SmtpClient`.

Parameters

host string
host
port int
port
username string
field (string)
password string
field (string)

struct SmtpResponse

XuAPI
pub struct SmtpResponse {
    pub code int
    pub text string
}

Purpose

Public struct `SmtpResponse`.

Parameters

code int
code
text string
text

read_response

XuAPI
pub fn read_response(fd int) SmtpResponse

Purpose

Reads single-line or multi-line SMTP response 250-first line 250-second line 250 final line Throws on failure.

Parameters

fd int
file descriptor (int)

Returns

SmtpResponse — a value of this type

new_client

XuAPI
pub fn new_client(endpoint string) SmtpClient

Purpose

Construct client.

Parameters

endpoint string
endpoint (string)

Returns

SmtpClient — a value of this type

(SmtpClient) connect

XuAPI
pub fn (c SmtpClient) connect() int

Purpose

Call `connect` on `SmtpClient`. Throws on failure.

Parameters

c SmtpClient
receiver SmtpClient (value receiver)

Returns

int — a value of this type

(SmtpClient) send_mail_on_fd

XuAPI
pub fn (c SmtpClient) send_mail_on_fd(fd int, msg Message) bool

Purpose

Method on `SmtpClient`: send mail on fd. Throws on failure.

Parameters

c SmtpClient
receiver SmtpClient (value receiver)
fd int
file descriptor (int)
msg Message
message (Message)

Returns

bool — true or false

(SmtpClient) close_conn

XuAPI
pub fn (c SmtpClient) close_conn(fd int)

Purpose

Method on `SmtpClient`: close connection.

Parameters

c SmtpClient
receiver SmtpClient (value receiver)
fd int
file descriptor (int)

struct SmtpPool

XuAPI
pub struct SmtpPool {
    pub client SmtpClient
    pub idle chan int
    pub max_idle int
}

Purpose

Public struct `SmtpPool`.

Parameters

client SmtpClient
field (SmtpClient)
idle chan int
field (channel; type chan int)
max_idle int
field (int)

open_pool

XuAPI
pub fn open_pool(endpoint string, max_idle int) SmtpPool

Purpose

Open pool.

Parameters

endpoint string
endpoint (string)
max_idle int
max_idle (int)

Returns

SmtpPool — a value of this type

(&SmtpPool) get_conn

XuAPI
pub fn (p &SmtpPool) get_conn() int

Purpose

Method on `&SmtpPool`: read conn.

Parameters

p &SmtpPool
receiver &SmtpPool (borrow)

Returns

int — a value of this type

(&SmtpPool) put_conn

XuAPI
pub fn (p &SmtpPool) put_conn(fd int)

Purpose

Method on `&SmtpPool`: put connection.

Parameters

p &SmtpPool
receiver &SmtpPool (borrow)
fd int
file descriptor (int)

(&SmtpPool) send_mail

XuAPI
pub fn (p &SmtpPool) send_mail(msg Message) bool

Purpose

Convenient delegate to send mail borrowing from pool Throws on failure.

Parameters

p &SmtpPool
receiver &SmtpPool (borrow)
msg Message
message (Message)

Returns

bool — true or false

(&SmtpPool) close

XuAPI
pub fn (p &SmtpPool) close()

Purpose

Method on `&SmtpPool`: close the resource.

Parameters

p &SmtpPool
receiver &SmtpPool (borrow)