tcpcmd.sendMail
Sending a Simple Email Message

The simplest way to send an email message is with the most powerful smtp client verb, tcpcmd.sendMail.

Each time you run tcpcmd.sendMail, one email message is sent to one or more recipients.

Here is what a very simple example of sendMail looks like:

tcpcmd.sendMail ("smtp.erols.com", "asg@erols.com", "dwiner@well.com", "Love Note", "We love Frontier, Dave!\rThanks!")

This sends the message that will appear as this:

Note that the second parameter shown above is "asg@erols.com". This is my email address (I'm the sender in this example), but I could use user.mailaddress, which is a Frontier database object containing the email name of the current Frontier user. In fact, that's the default parameter if you don't provide it.

New in Version 1.0b7.3 - The second parameter has become much more powerful by letting you specify "To:", "Cc:", and "Bcc:" addresses.
The syntax of tcpcmd.sendMail is:

tcpcmd.sendMail (emailHost, fromAddress, toAddress, emailSubject, emailData [,mimetype] [,timeout])

where:

  • emailHost is a string containing the name of your smtp server (or whichever smtp server you want to use).

    "smtp.erols.com"

  • fromAddress a string containing the email address shown as the sender in your email message. If you pass an empty string for email address, the email address stored in user.mailaddress is used.

    "asg@erols.com"

  • toAddress (See note below on new feature of this parameter) is the email address of the intended recipient(s) and can be any one of the following Frontier data types (or an address pointing to one of these types):

    • a string containing a single email address

      "dwiner@well.com"

    • a string containing several email addresses, separated by commas

      "dwiner@well.com, asg@erols.com, leonardr@aladdinsys.com"

      Note that this is a common format for recipient lists in many electronic mail programs, like Eudora.

    • a list containing one or more strings that are single email addresses

      { "dwiner@well.com", "asg@erols.com", "leonardr@aladdinsys.com" }

    • the address to a table containing one or more string objects that are single email addresses

      @scratchpad.recipients
      An example of such a table might look like this:

    New in Version 1.0b7.3 - the toAddress parameter can now be a list with up to three items. The items represent, in order, the "To:", "Cc:", and "Bcc:" addresses. Each item in the list can be any of the types listed above. To omit "Cc:" and include "Bcc:", use an empty string for the second item in the list: myRecipientList = {"you.somewhere.com", "", "bccRecip1.company.com"}
    tcpcmd.sendMail("smtp.erols.com","asg@erols.com",myRecipientList, ...)

  • emailSubject a string containing the text that will appear in the Subject line of your note.

    "This is the Subject Line"

  • emailData is the text of your message and can be one of the following Frontier data types, or an address pointing to, one of these types:
    • a string containing the message text

      "This is the text of the message."
    • a wpText object containing the message text

      @people.asg.myWPtextMessage
      Note that here we are passing the address of a wpText object. We don't have to pass the address, though.
    • a fileSpeccontaining the path to a text file containing the message text

      fileSpec("Hard Drive:Desktop Folder:Message.txt")
    Again, these various possibilities for the email message text help scripters implement their bulk mail applications.

  • mimetype an optional string containing the mime type of the message text. The default mimetype used is "text/plain". This parameter refers only to the message text and does not indicate an attachment.

  • timeout an optional number containing the number of seconds sendMail will wait for the smtp host at each step in the sending process before it gives up and returns to the caller. The default timeout used is defined in tcpcmd.timeouts.smtp.

Returns

  • true if the message is sent
  • a script error stating the reason for failure
    sendMail attempts to gracefully disconnect from the smtp host if an error occurs.

Current Limitations and Restrictions

Attachments are not currently supported. Only the US-ASCII character set is supported in this version.


This page was last built on 9/16/98; 4:36:10 PM ET by Alan German, asg@erols.com. At the moment, I am using Macintosh OS to work on this website. The "Electric Cactus" graphic is based on original artwork owned by UserLand Software and is used with their permission.