
---@class socket_smtp_message*
---@field headers? table<string, string> Mail header.
---@field body? string|ltn12_source The body of the email.

---@class socket_smtp_mail*
---@field from string sender.
---@field rcpt string|string[] recipient.
---@field source? ltn12_source Email source.
---@field user? string username.
---@field password? string password.
---@field server? string SMTP server.
---@field port? integer SMTP port.
---@field domain? string HELO/EHLO domain。
---@field create? function socket Create function.

---@class socket_smtp_connection*
local socket_smtp_connection = {}

---@class socket_smtp*
---@field TIMEOUT number Default timeout.
---@field SERVER string Default server.
---@field PORT integer Default port.
---@field DOMAIN string Default domain.
---@field ZONE string Default time zone.
---@type socket_smtp*
local M = {}

M.TIMEOUT = 60
M.SERVER = nil
M.PORT = 25
M.DOMAIN = nil
M.ZONE = nil

--- Open an SMTP connection.
---@param server? string server.
---@param port? integer port.
---@param create? function socket Create function.
---@return socket_smtp_connection*? connection Connection object.
---@return string? errMsg error message.
function M.open(server, port, create) end

--- Construct a MIME message source.
---@param message socket_smtp_message* Message parameters.
---@return ltn12_source source source function.
function M.message(message) end

--- Send mail.
---@param mail socket_smtp_mail* Email parameters.
---@return any result result.
function M.send(mail) end

--- LuaSocket try function.
---@param ... any value.
---@return any ... Non-error return value.
function M.try(...) end

return M
