Sends an email using a custom port.

Added in 2.2

Syntax

Status = SRP_Mail("SendUsing", Server, Port, UseTLS, Subject, Sender, Recipients, Body, Attachments, Importance)

Returns

If the email sends successfully, then 1 is returned. If the email cannot be sent, then a string describing the error is returned.

Parameters

ParameterDescription
ServerServer address, username, and password. (See Remarks) Required.
PortServer port number. Required.
UseTLSSet to 1 to use TLS protocol or 0 to use no security. Required.
SubjectSubject line of the email.
SenderSingle email address indicating who the email is from. Required.
RecipientsEmail addresses to whom the email will be sent. Includes Cc and Bcc. (See Remarks) Requires at least one.
BodyBody of the email. Support HTML formatting.
Attachments@FM or @VM delimited list of filenames to be attached to the email.
Importance"Low", "Normal", or "High". Default is "Normal" if omitted.

Remarks

The SendUnsecure service sends an email on port 25 using no encryption. Few email servers support this option these days, which is why we recommend using the Send service whenever possible, which uses the same parameters as this service for your convenience.

Server

The Server parameter is a multivalued structure containing three discreet fields.

FieldNameDescription
<1>
AddressThis is the server's address (e.g., smtp.gmail.com) or direct IP address.
<2>
UsernameThis is the username required to log into the server to send an email.
<3>
PasswordThis is the password required to log into the server to send an email.

Port

This is the port number that SRP_Mail should communicate through. The standard port for unsecure emails is 25, and the standard port for TLS is 587. If your email server uses a different port, simply pass it here.

UseTLS

This determines if the email is transported using TLS encryption protocol or no encryption at all. SSL is not supported as of 2.2.

Subject

This is the text that will appear in the subject line of your email.

Sender

This is the email address of the one sending the email. You may optionally include a name with email by using the format "name(email)", e.g., "John Doe (johndoe@mydomain.com)"

Recipients

The Recipients parameter is a multivalued structure with the following fields:

FieldNameDescription
<1>
ToA comma delimited list of email addresses. To pass name with email, use format name(email). There must be at least one email here.
<2>
CcA comma delimited list of carbon-copy email addresses. To pass name with email, use format name(email).
<3>
BccA comma delimited list of blind carbon-copy email addresses. To pass name with email, use format name(email).

Note: The emails in these fields are comma delimited, not @VM delimited.

Body

This is the text that appears in the body of the email. If you want to pass formatted text, you must pass well-formatted HTML beginning with <html> and ending with </html>. Failure to do so will cause this service to think you are passing plain text.

Attachments

This is an @FM or @VM delimited list of file paths pointing to existing files you want attached to the email when sent.

Importance

This optional parameter lets you specify the importance level of the email. Note that not all email clients pay attention to this field, so your mileage may vary. You may pass "Low", "Normal", or "High". Leave this blank to set the importance to Normal.

Example

$insert LOGICAL
$insert SRPMAIL_INSERTS 

Server = ""
Server<1> = "mymail.somedomain.com"
Server<2> = "myusername"
Server<3> = "password"

Result = SRP_Mail("SendUsing", Server, 587, Yes$, "Test Subject Line", "myemail@somedomain.com", "myfriend@somedomain.com", "Hello World!")
  • No labels