Description: This function sends a string to an email server using the Simple Mail Transport Protocol (SMTP)
Returns: Nothing
Usage: Script
Format: \SendMail(Server, To, From, Subject, Message, Error [,Attachments, AttachmentStreams, OptionalHeaders, ErrorText, SenderMailbox, Username, Password])
Parameters: Server { text } { required } { no default: }
Any text or buffer expression of the mail server name or IP address
To { text } { required } { no default: }
Any text or buffer expression of the address of destination
From { text } { required } { no default: }
Any text or buffer expression of the address of the person from whom the mail is from
Subject { text } { required } { no default: }
Any text or buffer expression of the subject of the message
Message { text } { required } { no default: }
Any text or buffer expression of the message – no attachments
Error { pointer } { required } { no default: }
A pointer to an error variable, set to 0 if OK. The Error parameter should initially be set Invalid by the caller. When this method is done, it will set Error to one of the following values:
|
Error |
Meaning |
|
0 |
Mail has been successfully sent. |
|
1 |
Unable to open a connection to the server. |
|
2 |
Server did not send a good SMTP welcome message. |
|
3 |
Server rejected SMTP HELO message. |
|
4 |
Server rejected SMTP MAIL message. |
|
5 |
Server rejected SMTP RCPT message. |
|
6 |
Server rejected SMTP DATA message. |
|
7 |
Server rejected message body. |
|
8 |
Badly formatted TO: address. |
|
9 |
Server does not support AUTH. |
|
10 |
Server does not support implemented AUTH. mechanisms. |
|
11 |
Failure to login to SMTP server. |
Attachments { array of text } { optional } { no default: }
An optional parameter that is an array of file names to be attached to the e-mail message.
AttachmentStreams { array of streams } { optional } { no default: }
An optional parallel array of attachment streams.
OptionalHeaders { text } { optional } { no default: }
A string of optional headers, separated by CRLF.
ErrorText { pointer } { optional } { no default: }
An optional pointer to the variable that holds the error text.
SenderMailbox { text } { optional } { no default: }
An optional parameter which is the SMTP reverse path. SenderMailbox overrides the From parameter. This parameter may be used as an alternative to the From parameter when specifying the "MAIL FROM" address in the SMTP. The From parameter would still be used when specifying the "From:" address in the e-mail header. SenderMailbox should be used only when an e-mail is intended to look like it came from a particular address, but has actually originated from another address.
Username { text } { optional } { no default: }
Allows a user name to be provided to email servers that require authentication.
Password { text } { optional } { no default: }
Allows a password to be provided to email servers that require authentication.
Comments: This function opens a TCP/IP socked on port 25 of the specified mail server. The Message is then sent using the SMTP protocol.
If both Username and Password are valid, then SendMail will attempt to login to the mail server before sending the email message. If the server does not support authentication, then SendMail will abort with an error message
If both Username and Password are valid, but the server does not support PLAIN authentication, then SendMail will abort with an error.
While PLAIN *must* be available, some server configurations require that a TLS connection (aka SSL) to be negotiated before allowing PLAIN. VTS does not support authentication over TLS. It is assumed that communication between the Email Server and the VTS client will be over a secure network such as an intranet.
If either Username or Password is missing or invalid, then the message will be sent without a login attempt.
Example:
\SendMail("192.168.0.201",
"sales@trihedral.com",
"vts@trihedral.com",
"Great Product!",
"VTS is Great\n\rMust buy lots!",
&ErrorCode);
See Also: