client
XuAPI
pub fn client(endpoint string) SmtpClient用途
客户端。
参数
endpointstring- endpoint(string)
返回
SmtpClient — 该类型的值
API
#github.com/xulang-org/packages/smtp扩展包 `smtp #github.com/xulang-org/packages/smtp`,由模块 github.com/xulang-org/packages 提供。
github.com/xulang-org/packages · 0.1.1 · 安装与使用
clientpub fn client(endpoint string) SmtpClient客户端。
endpoint stringSmtpClient — 该类型的值
poolpub fn pool(endpoint string, max_conns int) SmtpPoolpool,返回 SmtpPool。
endpoint stringmax_conns intSmtpPool — 该类型的值
struct Messagepub struct Message {
pub from string
pub to string
pub subject string
pub body string
}公开结构体 `Message`。
from stringto stringsubject stringbody stringstruct SmtpClientpub struct SmtpClient {
pub host string
pub port int
pub username string
pub password string
}公开结构体 `SmtpClient`。
host stringport intusername stringpassword stringstruct SmtpResponsepub struct SmtpResponse {
pub code int
pub text string
}公开结构体 `SmtpResponse`。
code inttext stringread_responsepub fn read_response(fd int) SmtpResponse读取响应。失败时 throw。
fd intSmtpResponse — 该类型的值
new_clientpub fn new_client(endpoint string) SmtpClient构造 client。
endpoint stringSmtpClient — 该类型的值
(SmtpClient) connectpub fn (c SmtpClient) connect() int在 `SmtpClient` 上调用 `connect`。失败时 throw。
c SmtpClientint — 该类型的值
(SmtpClient) send_mail_on_fdpub fn (c SmtpClient) send_mail_on_fd(fd int, msg Message) bool`SmtpClient` 上的方法:sendmail于fd。失败时 throw。
c SmtpClientfd intmsg Messagebool — 是否成立
(SmtpClient) close_connpub fn (c SmtpClient) close_conn(fd int)`SmtpClient` 上的方法:关闭连接。
c SmtpClientfd intstruct SmtpPoolpub struct SmtpPool {
pub client SmtpClient
pub idle chan int
pub max_idle int
}公开结构体 `SmtpPool`。
client SmtpClientidle chan intmax_idle intopen_poolpub fn open_pool(endpoint string, max_idle int) SmtpPool打开pool。
endpoint stringmax_idle intSmtpPool — 该类型的值
(&SmtpPool) get_connpub fn (p &SmtpPool) get_conn() int`&SmtpPool` 上的方法:读取 conn。
p &SmtpPoolint — 该类型的值
(&SmtpPool) put_connpub fn (p &SmtpPool) put_conn(fd int)`&SmtpPool` 上的方法:put连接。
p &SmtpPoolfd int(&SmtpPool) send_mailpub fn (p &SmtpPool) send_mail(msg Message) bool`&SmtpPool` 上的方法:sendmail。失败时 throw。
p &SmtpPoolmsg Messagebool — 是否成立
(&SmtpPool) closepub fn (p &SmtpPool) close()`&SmtpPool` 上的方法:关闭资源。
p &SmtpPool