mail

Send email.

MAIL

NAME

mail - Sends email.

SYNOPSIS

mail(from:"string",to:"string",[cc:"string",bcc:"string",ct:"string",error:variable,charset:"string", encoding:"base64|quoted-printable",domain:"string",subject:"string",mailhost:"string",port:integer, timeout:integer,message:"string",header:"string",headercharset:"string",attach:"string", binaryfile:"string",compilefile:"string",textfile:"string",file:"string", attachbinaryfile:"string",attachcompilefile:"string",attachtextfile:"string",attachfile:"string");

DESCRIPTION

This function is used to send email.

The parameters ct, charset and encoding must be specified before the parameters to include a message or an attachment. If ct is not defined or is empty, ct is guessed from the file extention. Inline text or attachment are set to text/plain by default as the content-type if it is not defined.

If the encoding is not defined and the content-type of the message is text/…, then the encoding is not encoded in based64. Otherwise it is.

Quoted-printable is defined in wikipedia as:

Any 8-bit byte value may be encoded with 3 characters: an "=" followed by two hexadecimal digits (0–9 or A–F) representing the byte’s numeric value. For example, an ASCII form feed character (decimal value 12) can be represented by "=0C", and an ASCII equal sign (decimal value 61) must be represented by "=3D". All characters except printable ASCII characters or end of line characters must be encoded in this fashion. All printable ASCII characters (decimal values between 33 and 126) may be represented by themselves, except "=" (decimal 61). ASCII tab and space characters, decimal values 9 and 32, may be represented by themselves, except if these characters would appear at the end of the encoded line. In that case, they would need to be escaped as "=09" (tab) or "=20" (space), or be followed by a "=" (soft line break) as the last character of the encoded line. This last solution is valid because it prevents the tab or space from being the last character of the encoded line. If the data being encoded contains meaningful line breaks, they must be encoded as an ASCII CR LF sequence, not as their original byte values, neither directly nor via "=" signs. Conversely, if byte values 13 and 10 have meanings other than end of line (in media types,[3] for example), then they must be encoded as =0D and =0A respectively. Lines of Quoted-Printable encoded data must not be longer than 76 characters. To satisfy this requirement without altering the encoded text, soft line breaks may be added as desired. A soft line break consists of an "=" at the end of an encoded line, and does not appear as a line break in the decoded text. These soft line breaks also allow encoding text without line breaks (or containing very long lines) for an environment where line size is limited, such as the "1000 characters per line" limit of some SMTP software, as allowed by RFC 2821. A slightly modified version of Quoted-Printable is used in message headers; see MIME#Encoded-Word.

PARAMETERS

from
Specifies who the email is from. Mandatary.
to
Specifies to who the email must be send. Mandatary.
cc
Sends a carbon copy to these addresses comma separated.
bcc
Blank carbon copy. Used to specify an email address but these adresses won’t appear in the email.
ct
Used to specify content-type.
error
Returns status in this hash array variable.
charset
Specifies charset, iso-8859-1, utf-8, etc.
encoding
Specifies encoding. base64 or quoted-printable.
domain
Specifies domain. By default, it is sednove.com.
subject
Specifies subject of email.
mailhost
Specifies mailhost. By default, it is localhost.
port
Specifies port for communication. By default, it is 25.
timeout
Specifies timeout in communication with mailhost. By default, it is 30 seconds.
message
Specifies message for email as string.
header
Specifies header to add to message.
headercharset
Specifies charset for header.
attach
Specifies a string to add as an attachment to the email.
binaryfile
Specifies a binary file to execute add add as a message.
compilefile
Specifies a file to compile and execute and add as a message
textfile
Specifies a text file to add as a message.
file
Guesses type of file (binary, compile, text) to add as a message. Guessing is based on extention.
attachbinaryfile
Specifies a binary file to execute and add as attachment.
attachcompielfile
Specifies a file to compile and execute and add as attachment.
attachtextfile
Specifies a text (which can be binary as opposed to a file to be compile or executed) to add as attachment.
attachfile
Specifies a file to add as attachment. Format is guessed, based on extention.

RETURN

Returns null or error in variable specified by error.

EXAMPLES

Note: In the followings examples, the _ between the { should be removed to make it work.

res={_{email(header:"Sender: Pierre.Laplante@sednove.com",from:"laplante@sednove.com",to:"laplante@sednove.com",message:"test 1");}}. return res=.
res={_{email();}}. return .*Parameters to and from must be set.*
res={_{email(xya:"abc");}}. return .*Parameter xya is not valid in email.*
res={_{email(to:"abc",from:"abc");}}. return .*At least one content must be specify.*
res={_{email(to:"abc");}}. return .*Parameters to and from must be set.*
res={_{email(from:"abc");}}. return .*Parameters to and from must be set.*
res={_{email(from:"laplante@sednove.com",to:"laplante@sednove.com");}}. return .*At least one content must be specify.*

res={_{email(from:"laplante@sednove.com",to:"",message:"test 1",error:t); t.errmsg;}}. return res=.*Parameters to and from must be set.*
res={_{email(from:"laplante@sednove.com",to:"laplante@sednove.com",message:"test 1");}}. return res=.
res={_{email(from:"laplante@sednove.com",to:"laplante@sednove.com",message:"test 2",subject:"test2");}}. return res=.
res={_{email(from:"laplante@sednove.com",to:"laplante@sednove.com",cc:"laplante.p@gmail.com",message:"test 3");}}. return res=.
res={_{email(from:"laplante@sednove.com",to:"laplante@sednove.com",cc:"laplante.p@gmail.com",
                bcc:"pierre.laplante@sednove.com",subject:"test 4 en français",
                message:"test 4 avec des accents.... été ou hiver");}}. return res=.

res={_{email(from:"laplante@sednove.com",to:"laplante@sednove.com",bcc:"laplante.p@gmail.com",
                subject:"test 5 en été 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 ",
                message:"test 5 en été 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 ");}}. return res=.

res={_{email(from:"laplante@sednove.com",to:"laplante@sednove.com",cc:"laplante.p@gmail.com",
                headercharset:"iso-8859-1",subject:esc(filter:"utf8latin1","test 6 en français."),
                charset:"utf-8",message:"test 6 avec des accents.... été ou hiver version 1.0");}}. return res=.

res={_{email(from:"laplante@sednove.com",to:"laplante@sednove.com",cc:"laplante.p@gmail.com",
                headercharset:"iso-8859-1",subject:esc(filter:"utf8latin1","test 7 en français."),
                charset:"iso-8859-1",message:esc(filter:"utf8latin1","test 7 avec des accents.... été ou hiver version 1.1"}}. return res=.));

res={_{email(from:"laplante@sednove.com",to:"laplante@sednove.com",cc:"laplante.p@gmail.com",
                subject:"test 8 en français.",encoding:"quoted-printable",
                message:"test 8 avec des accents.... été ou hiver version 1.1");}}. return res=.

res={_{email(from:"laplante@sednove.com",to:"laplante@sednove.com",cc:"laplante.p@gmail.com",
                subject:"test 9 en français.",encoding:"base64",charset:"utf-8",
                message:"test 9 avec des accents.... été ou hiver version 1.2 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 ");}}. return res=.

res={_{email(from:"laplante@sednove.com",to:"laplante@sednove.com",cc:"laplante.p@gmail.com",
                subject:"test 9 en français plusieurs messages.",encoding:"quoted-printable",
                message:"test 9 avec des accents.... été ou hiver version 1.1",message:"version2",message:"version3");}}. return res=.

res={_{email(from:"laplante@sednove.com",to:"laplante@sednove.com",cc:"laplante.p@gmail.com",
                subject:"test 9 en français attach.",encoding:"quoted-printable",
                message:"test 9 avec des accents.... été ou hiver version 1.1",charset:"utf-8",attach:"123 attach été.");}}. return res=.

res={_{email(from:"laplante@sednove.com",to:"laplante@sednove.com",
                cc:"laplante.p@gmail.com",
                subject:"test 10 ct en français attach.",encoding:"quoted-printable",
                message:"test 10 avec des accents.... été ou hiver version 1.2",
                charset:"utf-8",encoding:"base64",ct:"",attachfile:"/html/heart.gif");}}. return res=.

res={_{email(from:"laplante@sednove.com",to:"laplante@sednove.com",
                cc:"laplante.p@gmail.com",
                subject:"test 11 test file ",
                message:"test 11 avec des accents.... été ou hiver version 1.2",
                charset:"utf-8",encoding:"base64",ct:"",attach:"été");}}. return res=.

res={_{
                remove("/tmp/tib.sn");
                write(data:"test {_{ a=5; a * 6; }}",file:"/tmp/tib.sn");
                compile(error:t,src:"/tmp/tib.sn",dst:"/tmp/tib.snc");
                email(from:"laplante@sednove.com",to:"laplante@sednove.com",
                cc:"laplante.p@gmail.com",
                subject:"test 12 test file ",
                binaryfile:"/tmp/tib.sn");
                remove("/tmp/tib.sn");
                }}. return .*Invalid opcode.*

res={_{
                remove("/tmp/tib.sn");
                write(data:"test {_{ a=5; a * 6; }}",file:"/tmp/tib.sn");
                compile(error:t,src:"/tmp/tib.sn",dst:"/tmp/tib.snc");
                email(from:"laplante@sednove.com",to:"laplante@sednove.com",
                cc:"laplante.p@gmail.com",
                subject:"test 12 test file ",
                binaryfile:"/tmp/tib.snc");
                remove("/tmp/tib.sn");
                }}. return res=.

res={_{
                remove("/tmp/tib.sn");
                write(data:"test été : {_{ a=5; a * 6; }}",file:"/tmp/tib.sn");
                compile(error:t,src:"/tmp/tib.sn",dst:"/tmp/tib.snc");
                email(from:"laplante@sednove.com",to:"laplante@sednove.com",
                cc:"laplante.p@gmail.com",
                subject:"test 13 binaryfile quotedprintable",
                encoding:"quoted-printable",
                binaryfile:"/tmp/tib.snc");
                remove("/tmp/tib.sn");
                }}. return res=.

res={_{
                remove("/tmp/tib.sn");
                write(data:"test été : {_{ a=5; a * 6; }}",file:"/tmp/tib.sn");
                compile(error:t,src:"/tmp/tib.sn",dst:"/tmp/tib.snc");
                email(from:"laplante@sednove.com",to:"laplante@sednove.com",
                cc:"laplante.p@gmail.com",
                subject:"test 14 binaryfile invalid encoding",
                encoding:"quoted-printxable",
                binaryfile:"/tmp/tib.snc");
                remove("/tmp/tib.sn");
                }}. return .*Invalid encoding.*

res={_{
                remove("/tmp/tib.sn");
                write(data:"test été : {_{ a=5; a * 6; }}",file:"/tmp/tib.sn");
                compile(error:t,src:"/tmp/tib.sn",dst:"/tmp/tib.snc");
                email(from:"laplante@sednove.com",to:"laplante@sednove.com",
                cc:"laplante.p@gmail.com",
                subject:"test 15 binaryfile base64 encoding ",
                encoding:"base64",
                binaryfile:"/tmp/tib.snc");
                remove("/tmp/tib.sn");
                }}. return res=.

res={_{
                remove("/tmp/tib.sn");
                write(data:"test été : {_{ a=5; a * 6; }}",file:"/tmp/tib.sn");
                email(from:"laplante@sednove.com",to:"laplante@sednove.com",
                cc:"laplante.p@gmail.com",
                subject:"test 16 compilefile base64 encoding ",
                encoding:"base64",
                compilefile:"/tmp/tib.sn");
                remove("/tmp/tib.sn");
                }}. return res=.

res={_{
                remove("/tmp/tib.sn");
                write(data:"test été : {_{ a=5; a * 6; }}",file:"/tmp/tib.sn");
                email(from:"laplante@sednove.com",to:"laplante@sednove.com",
                cc:"laplante.p@gmail.com",
                subject:"test 17 compilefile quoted-printable encoding ",
                encoding:"quoted-printable",
                compilefile:"/tmp/tib.sn");
                remove("/tmp/tib.sn");
                }}. return res=.

res={_{
                remove("/tmp/tib.sn");
                write(data:"test été : {_{ a=5; a * 6; }}",file:"/tmp/tib.sn");
                email(from:"laplante@sednove.com",to:"laplante@sednove.com",
                cc:"laplante.p@gmail.com",
                subject:"test 18 compilefile no encoding ",
                compilefile:"/tmp/tib.sn");
                remove("/tmp/tib.sn");
                }}. return res=.

res={_{
                remove("/tmp/tib.sn");
                write(data:"test été : {_{ a=5; a * 6; }}",file:"/tmp/tib.sn");
                email(from:"laplante@sednove.com",to:"laplante@sednove.com",
                cc:"laplante.p@gmail.com",
                subject:"test 19 textfile no encoding v1",
                textfile:"/tmp/tib.sn");
                remove("/tmp/tib.sn");
                }}. return res=.

res={_{
                remove("/tmp/tib.sn");
                write(data:"test été : {_{ a=5; a * 6; }}",file:"/tmp/tib.sn");
                email(from:"laplante@sednove.com",to:"laplante@sednove.com",
                cc:"laplante.p@gmail.com",
                subject:"test 20 textfile encoding quoted-printable v1",
                encoding:"quoted-printable",
                textfile:"/tmp/tib.sn");
                remove("/tmp/tib.sn");
                }}. return res=.

res={_{
                remove("/tmp/tib.sn");
                write(data:"test été : {_{ a=5; a * 6; }}",file:"/tmp/tib.sn");
                email(from:"laplante@sednove.com",to:"laplante@sednove.com",
                cc:"laplante.p@gmail.com",
                subject:"test 21 textfile encoding base64 v1",
                encoding:"base64",
                textfile:"/tmp/tib.sn");
                remove("/tmp/tib.sn");
                }}. return res=.

res={_{
                email(from:"laplante@sednove.com",to:"laplante@sednove.com",
                cc:"laplante.p@gmail.com",
                subject:"test 22 textfile (really binary) encoding quoted-printable v2",
                encoding:"quoted-printable",
                textfile:"/html/heart.gif");
                }}. return res=.

res={_{
                email(from:"laplante@sednove.com",to:"laplante@sednove.com",
                cc:"laplante.p@gmail.com",
                subject:"test 23 message attach",
                message:"test 23 attach file",
                encoding:"base64",
                attachfile:"/html/heart.gif");
                }}. return res=.

res={_{
                remove("/tmp/tib.sn");
                write(data:"test été : {_{ a=5; a * 6; }}",file:"/tmp/tib.sn");
                email(from:"laplante@sednove.com",to:"laplante@sednove.com",
                cc:"laplante.p@gmail.com",
                subject:"test 24 message attach text file no encoding",
                message:"test 24 attach file",
                attachtextfile:"/tmp/tib.sn");
                remove("/tmp/tib.sn");
                }}. return res=.

res={_{
                remove("/tmp/tib.sn");
                write(data:"test été : {_{ a=5; a * 6; }}",file:"/tmp/tib.sn");
                email(from:"laplante@sednove.com",to:"laplante@sednove.com",
                cc:"laplante.p@gmail.com",
                subject:"test 25 message attach text file no encoding",
                message:"test 25 attach file",
                attachcompilefile:"/tmp/tib.sn");
                remove("/tmp/tib.sn");
                }}. return res=.

res={_{
                remove("/tmp/tib.sn");
                write(data:"test été : {_{ a=5; a * ; }}",file:"/tmp/tib.sn");
                email(from:"laplante@sednove.com",to:"laplante@sednove.com",
                cc:"laplante.p@gmail.com",
                subject:"test 26 message attach text file no encoding",
                message:"test 26 attach file with error in compile file",
                attachcompilefile:"/tmp/tib.sn");
                remove("/tmp/tib.sn");
                }}. return .*Error while parsing template.*

res={_{
                remove("/tmp/tib.sn");
                write(data:"test été : {_{ a=5; a * ; }}",file:"/tmp/tib.sn");
                compile(error:t,src:"/tmp/tib.sn",dst:"/tmp/tib.snc");
                email(from:"laplante@sednove.com",to:"laplante@sednove.com",
                cc:"laplante.p@gmail.com",
                subject:"test 27 message attach binary file no encoding",
                message:"test 27 attach file ",
                attachbinaryfile:"/tmp/tib.snc");
                remove("/tmp/tib.sn");
                }}. return res=.

SEE ALSO

AUTHOR

Written by Pierre Laplante and Caroline Laplante, <laplante@sednove.com>

MODIFICATIONS

1.0 2014-09-09 21:24:14 laplante@sednove.com

Edit

© 2024 extenso Inc. All rights reserved.