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 |
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 One of fields path, data, file are required. |
OPTIONS | a table describe sendmail options |
SEND_PARAMS | 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:
- from string or FROM
- to string or TO
- smtp_server string or SERVER
- message string or MESSAGE
- options optional OPTIONS
Returns:
- int or nil number of the sent messages
- string error message
Usage:
sendmail('me@host', 'to@host', 'host', {'test', 'hello'})
- sendmail (params)
-
Send mail
Parameters:
- params SEND_PARAMS
Returns:
- int or nil number of the sent messages
- string error message
Usage:
sendmail('me@host', 'to@host', 'host', {'test', 'hello'})
Tables
- FROM
-
a table describe FROM header
Fields:
- TO
-
a table describe TO headers
Fields:
- SERVER
-
a table describe smtp server
Fields:
- MESSAGE
-
a table describe message
Fields:
- subject string or SUBJECT (or first value of table)
- text string or TEXT if no mime_type then 'text/plain' used (or second value of table)
- html string or TEXT if no mime_type then 'text/html' used
- file string, FILE or {FILE,...} path, file or array of files
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:
- 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
- SEND_PARAMS
-
Send mail params as single table
Fields: