send. Sending a message via e-mail

^mail:send[message]

The method sends message to the specified e-mail address. One can specify several addresses separated by comma.

^mail:send[
      $.from[
Fred <freddy@hotmail.com>]
      $.to[
Peter <peter@hotmail.com>]
      $.subject[
Hi there!!!]
      $.text[
How is it going? Haven't seen you for ages!]
]
As a result of this code, a message will be sent to peter@hotmail.com containing text: "How is it going? Haven't seen you for ages!"

message-is a hash, where you can specify the following keys:
·header_field  
·text  
·html  
·file  
·charset  
·options  
·print-debug   [3.4.0]  

Note: It is recommended that in
errors-to header you specify the address to which delivery report will be sent if the message cannot be delivered to the addressee. Default value is "postmaster".

charset
-if this key is specified, the headers and text blocks will be transcoded using specified charset. Default charset for all messages is that, specified in $request:charset (i.e. is not transcoded).

Example:
$.charset[koi8-r]

options
-these options will be passed to command line of sendmail program (only on UNIX).

print-debug
-the message text will be printed instead of sending message.

You can also specify all message headers, specifying their values in the following way (short form):
$.header_field[value]

or with parameters (complete form):

$.
header_field[
    $.value[
string]
    $
.parameter[string]
]


Examples:
$.from[Fred <freddy@hotmail.com>]
$.to[
Peter <peter@hotmail.com>]
$.subject[How is it going? Haven't seen you for ages!]
$.x-mailer[Parser 3]

Along with the header you can send one or both text blocks
(text, html) as well as any number of blocks file and message (see below).
If you send both text blocks, section
MULTIPART/ALTERNATIVE will be formed, and having received this message, modern mail clients will display HTML, whereas obsolete ones will display plain text.

short form:
$.text[string]

full form:
$.text[
    $.value[
string]
    $
.header_field[value]
]


…where
value is the value of text block and you can specify all header fields the same way we did with hash message (see above).
Note: It is not imperative to specify
content-type header-it will be generated automatically. This header does not affect transcoding process and is used only to tell mail client what charset it must use to display message.

Sending HTML. Short form:

$.html{
string}

full form:
$.html[
    $.value{
string}
    $
.header_field[value]
]


Curly brackets are necessary to switch default transformation type to HTML.

Attaching a file. Short form:

$.file[
file]

full form:

$.file[
    $.value[
file]
    $.name[filename]
    
$.content-id[XYZ]      [3.2.2]
    
$.format[uue|base64]   [3.2.2]
    $
.header_field[value]
]


File
is an object of class file, which will be attached to the message. MIME-type of sent data (content-type header of a part) is determined according to table MIME-TYPES (see also Configuration method).

Filename
is the name that the file to be sent will bear.
By default the file will be sent in uuencode form.

Default file encoding
format is base64 since version 3.4.0 and uue prior version 3.4.0.

Attaching a message:
$.message[message_text]

The format of the message is the same as that of the whole method's parameter.

There may be several attachments. In this case you must add an integer after the name.
Example:
    $.file
    $.file
2
    $.message
    $.message
2

Example of how to use alternative blocks and attachments
^mail:send[
    $.from[
Fred <freddy@hotmail.com>>]
    $.to[
Peter <peter@hotmail.com>]
    $.subject[
How is it going?]
    $.text[
How is it going? It's really great in here!!!]
    $.html{
How is it going? It's really <b>great</b> in here!!!
        <br /><img src="cid:pic2" border="0" width="100" height="50" />
    }
    $.file[^
file::load[binary;perfect_life1.jpg]]
    $.file2[
        $.value[^file::load[binary;perfect_life2.jpg]]
        $.name[
pf_life2.jpg]
        $.content-id[
pic2]
    ]
]

As a result, a message will be sent to
peter@hotmail.com containing text "How is it going? It's really great in here!!!" in plain text and HTML. Two photographs will be attached to the message to support the idea, and on these photos…


Copyright © 1997–2021 Art. Lebedev Studio | http://www.artlebedev.com Last updated: 02.03.2011