Biferno 1.7 Tabasoft.it

Application: ItaliaScuola Back-Office3
Reference
Admin | Edit | Reference | Cache | Logs
Click on a class name to see the description of that particular class:

Predefined Classes

ansi
array
biferno
boolean
cacheItem
char
classInfo
client
collection
curApp
curFile
curScript
db
double
error
file
folder
header
httpPage
imageUtils
int
long
memberInfo
multipart
object
ref
regexp
request
search
serverInfo
smtp
stackItem
string
time
unix
unsigned
 

Application Classes

Banner
BrowserBar
Ctrl_Form
FCKeditor
Form
GridChartGraph
Histogram
LocalDate
Result
condb
cookie
folderExt
headerExt
httpExt
mysqlFulltext
objHtml
requestExt
tableExport
utils
 

Functions

Functions

smtp

Method:

SendMail

static string SendMail(string host, string from, string to, string text, string auth)

Description:

Is the simplest way to send an email message from a Biferno script.

Parameters:
host

specifies the name or address of the SMTP server we want to use to send our email

from

specifies the email address to be used as the address of the sender of the message. This is the user who contacts the smtp server and can be also different from the header field "From" (if any)

to

is the email address of the receiver, i.e. the person we want to address the message to. Can be also a sequence of adresses (comma separated)

text

is the message text, possibly including part of the SMTP header (in particular the subject field)

auth
Returns:

A string containing the description of an error (or warning) generated by the SMTP server (if any) or an empty string if the mail was successfully sent. This allows us to verify if the message has been correctly sent. If errors in the parameters are discovered (e.g. a wrong SMTP server name), the SendMail method generates an error of the smtp class.

Notes:

The following script shows how to use the SendMail method:

email_host = "mailserver.mydomain.com"
email_from = "me@mydomain.com"
email_to = "him@hisdomain.com"
email_text = "Subject: SendMail Test\r\n\r\n"
email_text += "Test email body."
status = smtp.SendMail(email_host, email_from, 
					email_to, 
					email_text)

Notice that in our example the message text contains a first line starting with the word “Subject” followed by the “:” character (semicolon) and by the subject text. This line is the header of our message. The body of the message must be separated from the header by two new lines (the combination of the characters CR, carriage return, and LF, line feed).

In the message header it is also possible to insert other fields that are specific to the SMTP header, such as “Cc:” (carbon copy), separated by a single new line character combination (CR+LF). The exact syntax is therefore: field_name + semicolon + value + CR + LF.

The SendMail method sends the message synchronously, which implies that script execution may block for several seconds waiting for an answer from the SMTP server. Additionally, no resend attempts take place if sending a message fails on the first attempt, and the email will not be sent to destination (unless the script is run again). See SendMailAsync method to avoid these problems.

Errors:

ErrNetOpenDriver, ErrNetOpenStream, ErrNetLostConnection, ErrNetDNR, ErrNetTruncated, ErrSmtpError

See also:

SendMailAsync

Implementation:
C
 

Return to the smtp class