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:

SendMailAsync

static string SendMailAsync(string host, string from, string to, string text, string filePath, unsigned minutes, string auth)

Begins a send of an asyncronous email message

Description:

The SendMailAsync works in a simple fashion. When the method is called, the email message is stored in a special format within the file specified by the filePath parameter. Once this step is completed, Biferno continues to process the current script with no further interruption, while another process running in parallel has the task of asynchronously sending the queued messages.

If an error occurs, Biferno will try to send the message again at regular intervals, until the timeout specified by the minutes parameter is reached. For this reason using the SendMailAsync method not only makes script execution faster, but also increases the likelihood that a message can be successfully sent in presence of temporary error conditions.

All attempts to send a message, i.e. the conversational protocol exchanges with the SMTP server, are stored in a log file in the same directory as the message file. The log file has the same name of the message file with the extension “.log” appended. The message file, together with the corresponding log file, is deleted from disk after the message has been successfully sent or after the timeout period expires.

The SendMailAsync method returns a string containing the file path of the message, including the name with which it has been stored on disk. This is because an ".xml" suffix is prepended and, if the file specified by the filePath parameter already exists, the method appends a progressive number to the file name.

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)

filePath

specifies the path of the file where the message is temporarily stored while it waits to be sent to the server

minutes

defines the timeout, in minutes, after which Biferno will stop trying to send the message in case of repeated errors

auth
Notes:

The following script shows how to use the SendMailAsync method. The script sends a message to a number of email addresses stored in an array, which could be filled e.g. by a database query.

email_host = "mailserver.mydomain.com"
email_from = "me@mydomain.com"
email_text = "Subject: SendMailAsync Test\r\n\r\n"
email_text += "Test email body."
email_timeout = 120 // Two hours
arr_email = array("user1@domain1.com", "user2@domain2.com", 
"user3@domain3.com", "user4@domain4.com")
n_email = arr_email.dim
email_sent = 0

for (i = 1; i <= n_email; i++)
{
	email_to = arr_email[i]
	if (email_to.IsEMail())
	{
		email_sent++
		email_file = "emails/email_" + email_sent

		smtp.SendMailAsync(email_host, email_from, email_to,
		email_text, email_file, email_timeout)
	}
}	

The format of a file is XML.

Implementation:
C
 

Return to the smtp class