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.
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 or string securety options. `true` mean use default options. Also you can pass protocol name as string. (required `LuaSec` module)
  • create function constructor for creating socket
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 string opened file handle (io.open in binary mode)
  • 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
SENDPARAMS
Send mail params as single table.

Fields:

Fields

DEFAULT_CHARSET
Default charset
DEFAULT_ENCODE
Default encoding
generated by LDoc 1.4.0