SENDMAIL        Send e-mail message to one or more recipients

<< Click to Display Table of Contents >>

Navigation:  Robo-FTP User's Guide > Script Programming > Script Commands > All Script Commands >

SENDMAIL        Send e-mail message to one or more recipients

Syntax:

SENDMAIL

[ server ] [ to name ] [ to email ] [ /options ]

Arguments:

[ server ]

Variable or string defining the server URL or IP address (e.g., smtp.mail.server or 209.198.128.17) of a SMTP mail server; the server port is always set to 25

 

[ to name ]

Variable or string defining a comma delimited list of "friendly names" that correspond to the email address(es) listed in the [ to email ] argument; you must provide this argument even if you do not  need to specify friendly names - in this case an empty string (e.g., "") is sufficient.

 

[ to email ]

Variable or string defining a comma delimited list of emails addresses to receive this message.

Options:

/bcc=xx

Variable or string defining a comma delimited list of emails addresses to receive a BCC of this message.

 

/cc=xx

Variable or string defining a comma delimited list of emails addresses to receive a CC of this message.

 

/port=nn

Use an alternate SMTP port instead of the default port 25. Many mail servers now accept TLS protected messages on port 587.

 

/pw=xx

Define optional password to use when logging on to the mail server (omit if not required by the SMTP server)

 

/ssl

Require explicit mode TLS encryption to be used when delivering the message to the remote server. The message will not be delivered unless the STARTTLS command succeeds. This option will often be used together with the /port option but cannot be combined with the /sslimp option.

 

/sslimp

Attempt an implicit TLS connection to the mail server. SMTP servers that use implicit TLS connections often use port 465. If you telnet to the SMTP port and get a scrambled, unreadable, or binary response it may be accepting only implicit TLS connections. This option cannot be combined with the /ssl option.

 

/stoponerror

When sending to multiple recipients, use this option to stop sending to any additional e-mail addresses when there is any error on the current message.

 

/timeout=nn

Specifies a time-out, in seconds, to wait for message to be sent (if omitted the time-out is set to 30 seconds). A %datetime value can also be given as an argument instead of a number of seconds.

 

/user=xx

Define optional user name to use when logging on to the mail server (omit if not required by the SMTP server)

 

/trust=xx

Action to take when an untrusted certificate is received from a TLS-secured mail server. Available options are ALLOW, ALL, PROMPT, and DENY. The default action if this option is not specified is DENY.

 

 

For new scripts, we recommend using the EMAIL script command instead, which supersedes both the CREATEMAIL and SENDMAIL commands.

 

This command sends an e-mail message previously created with the CREATEMAIL command via a SMTP e-mail server to one or more recipients. All of the arguments to this command are required, however [ to name ] may be an empty string.

 

The same message is sent each time SENDMAIL is called unless CREATEMAIL is called again to change the message.

 

Consider the following example where an e-mail message is created and then sent to one recipient.

 

;; create the message

SET from = "Acme Widget Co. Sales"  

SET email = "[email protected]"

SET subj = "Thanks for your order!"

SET body = "We appreciate your business."

SET attach = ""

CREATEMAIL from email subj body attach

;; send the message

SENDMAIL "120.33.13.10" "Joe Blow" "[email protected]"

 

Consider the following example where authentication is required on the SMTP server (not all mail servers will require authentication.)

 

SET server = "smtp.mail.server"

SET to = "Ray Johnson"

SET email = "[email protected]"

SENDMAIL server to email /user=smtpid /pw=smtppw

 

Consider the following example where the same message is sent directly to three recipients and /cc copied to two others.

 

SET server = "smtp.mail.server"

SET to = "Ray Johnson,Dick Martin,Dan Rowan"

SET email = "[email protected],[email protected],[email protected]"

SET email_cc = "[email protected],[email protected]"

SENDMAIL server to email /cc=email_cc

 

It is possible to send friendly names in the /cc or /bcc list with this format: FriendlyName<EmailAddress>   For example:

 

SET server = "smtp.mail.server"

SET to = "Ray Johnson"

SET email = "[email protected]"

SET email_cc = "Joe Blow<[email protected]>,Dan Rowan<[email protected]>"

SENDMAIL server to email /cc=email_cc

 

Important

To cut down on spam, some mail servers now require that the email address in the FROM line match an existing mailbox on the server. If your mail server returns an error when you call the SENDMAIL command, please check the FROM email address. Also, to fight botnets, some Internet Service Providers are now blocking outbound traffic on port 25 by default so you may need to contact your network administrator or ISP before using an external mail server

 

Here is an example using the /ssl and /port options together:

 

SENDMAIL "mail.domain.com" "" "[email protected]" /user="joeb" /pw="secret" /port=587 /ssl

 

If you encounter errors when using this command you may be able to discover the cause by examining the Trace Log and looking for problems in the SMTP conversation between Robo-FTP and your email server. Also, because malware infections are so often to send spam, your virus scanner may block Robo-FTP's ability to send email. This possibility is worth exploring if Robo-FTP reports that the SMTP connection or socket was closed unexpectedly.

 

 

Related command(s): CREATEMAIL, GETMAIL, MAILTO

See also: Sending and Receiving E-mail, Sending SMS text messages