Module sendmail

Functions

sendmail (from, to, smtp_server, message, options) Send mail.
sendmail (params) Send mail.

Tables

FROM a table describe FROM header.
TO a table describe TO headers.
SERVER a table describe smtp server.
SSL a table describe SSL securety options.
MESSAGE a table describe message.
SUBJECT a table describe subject.
TEXT a table describe text part in message.
FILE a table describe attached file in message.
OPTIONS a table describe sendmail options.
CURL a table describe the cURL IO backend
SENDPARAMS Send mail params as single table.

Fields

DEFAULT_CHARSET Default charset
DEFAULT_ENCODE Default encoding


Functions

sendmail (from, to, smtp_server, message, options)
Send mail.

Parameters:

Returns:

  1. int or nil number of the sent messages
  2. string error message

Usage:

    sendmail('me@host', 'to@host', 'host', {'test', 'hello'})
sendmail (params)
Send mail.

Parameters:

Returns:

  1. int or nil number of the sent messages
  2. string error message

Usage:

    sendmail('me@host', 'to@host', 'host', {'test', 'hello'})

Tables

FROM
a table describe FROM header.

Fields:

  • title optional string title used in header (or first value of table)
  • address string email address
  • charset optional string title charset
  • encode optional string ecoding used for title
TO
a table describe TO headers.

Fields:

  • title optional string title used in header (or first value of table)
  • address string or {string,...} email address
  • charset optional string title charset
  • encode optional string ecoding used for title
SERVER
a table describe smtp server.

Fields:

  • address string
  • port number or string (default 25 and 465 if you set `ssl` options)
  • user string
  • password string
  • ssl SSL, boolean, string or opaque securety options. `true` mean use default options. Also you can pass protocol name as string. (required `LuaSec` module). opaque value used with custom `create` function.
  • create function constructor for creating socket. If `ssl` option is provided then it pass to `create` function without any changes.
SSL
a table describe SSL securety options. For more information see documentation for `LuaSec` module.
Library use similar mechanism to find CA file as in cURL library.
Library use environment variables to find CA file.
On Windows library also search in system directory. (required `lua-path` module)
For more information see SSL Certificate Verification for cURL library.

Fields:

Usage:

    ssl = {verify = "none"} -- ignore sert
MESSAGE
a table describe message.

Fields:

Usage:

    msg = {'this is subject'}
    msg = {'this is subject';'this is text'}
    msg = {subject = 'this is subject';'this is text'}
    msg = {'this is subject';text='this is text'}
    msg = {'subject', 'text', file = 'path/to/file'}
SUBJECT
a table describe subject.

Fields:

  • title string subject's title (or first value of table)
  • charset optional string title charset
  • encode optional string ecoding used for title
TEXT
a table describe text part in message.

Fields:

FILE
a table describe attached file in message. One of fields path, data, file are required. If no name and path is setted then name sets to basename of file.

Fields:

  • name string attachment's name
  • path optional string surce file path
  • data optional string content of attachment
  • file optional file opened file handle (io.open in binary mode)
  • source optional ltn12.source source of file content
  • charset optional string
  • encode optional string
  • mime_type optional string Default 'application/octet-stream'
  • disposition optional string Default 'attachment'
  • headers optional table
OPTIONS
a table describe sendmail options.

Fields:

  • confirm_sending boolean
CURL
a table describe the cURL IO backend

Fields:

  • async optional boolean if set to true then sendmail just init/create a cURL easy handle and returns it. So it wil be possible to use this handle to perform async IO using cURL multi handle. User code responsible for close this handle.
  • handle cURL::easy pass existing cURL easy handle. sendmail does not close this handle. So it will be possible to reuse the same easy handle to send multiple emails.
SENDPARAMS
Send mail params as single table.

Fields:

Fields

DEFAULT_CHARSET
Default charset
DEFAULT_ENCODE
Default encoding
generated by LDoc 1.4.6 Last updated 2021-08-01 09:58:09