net.smtp #
fn new_client #
fn new_client(config Config) !&Client
new_client returns a new SMTP client and connects to it
fn BodyType.from #
fn BodyType.from[W](input W) !BodyType
fn ReplyCode.from #
fn ReplyCode.from[W](input W) !ReplyCode
enum BodyType #
enum BodyType {
text
html
}
struct Attachment #
struct Attachment {
pub:
cid string
filename string
bytes []u8
}
struct Client #
struct Client {
Config
mut:
conn net.TcpConn
ssl_conn &ssl.SSLConn = unsafe { nil }
reader ?&io.BufferedReader
pub mut:
is_open bool
encrypted bool
}
fn (Client) reconnect #
fn (mut c Client) reconnect() !
reconnect reconnects to the SMTP server if the connection was closed
fn (Client) send #
fn (mut c Client) send(config Mail) !
send sends an email
fn (Client) quit #
fn (mut c Client) quit() !
quit closes the connection to the server
struct Config #
struct Config {
pub:
server string
port int = 25
username string
password string
from string
ssl bool
starttls bool
timeout time.Duration
}
Config stores the settings used to connect a new SMTP client.
struct Mail #
struct Mail {
pub:
from string
to string
cc string
bcc string
date time.Time = time.now()
subject string
body_type BodyType
body string
attachments []Attachment
boundary string
}