by Marie P. Folker, <editor@filemakermagazine.com>, http://www.isoproductions.com
MailTo
Sending Mail From A Web Page
BONUS: DATABASE.FP3 and HTML files
PLATFORM: Mac/Win
There are two ways to send email with FileMaker Pro. The first way involves the Send Mail script step and an email client. The second is through Web Companion. In this article and accompanying bonus file, we'll look closely at the fundamental requirements of sending mail through a Web page with the assistance of Web Companion.
Because Web Companion doesn't send mail through an email client like Outlook Express or Claris Emailer, we need to use a Simple Mail Transfer Protocol server, generally referred to as an SMTP server.
The SMTP Server
Simple Mail Transfer Protocol (SMTP) is the Internet's standard host-to-host mail transport protocol and traditionally operates over TCP port 25. Sendmail is probably the most popular UNIX server SMTP software.
SMTP communicates via an asymmetric request-response protocol popularized in the early 1980s, and still commonly seen in mail protocols today. The protocol is designed to be understood by both human and computer.
From the sender's viewpoint, the request replies always take the form of text lines, each starting with a three-digit code identifying the result of the operation, a continuation character to indicate another lines following, and then arbitrary text information designed for human interpretation.
If mail delivery fails, sendmail (the most important SMTP implementation and not to be confused with the Send Mail script step) will queue mail messages and retry delivery later. However, a timeout algorithm is used, and no mechanism exists to poll all Internet hosts for mail, nor does SMTP provide any mailbox facility, or any special features beyond mail transport. Fortunately, this is all Web Companion needs in order to relay a composed email through the SMTP server to its intended destination.
Required Email Information
Much like addressing email using your favorite email client, we need to specify the following attributes:
MailTo (who your sending the email to)
MailFrom (who it's from)
MailSub (the text that appears as the subject of the email)
MailHost (the name of the SMTP server handling the transfer)
MailFormat (the text document that merges the field data producing a neat formatted email body)
If desired, you can also include:
MailCC (carbon copy)
MailBCC (blind carbon copy)
This information is contained in the HTML document that submits that information for processing by Web Companion.
The Form Document
Let's take a look at the form portion of the "default.htm" page that contains the Mail family of tags:
<FORM ACTION="FMPro" METHOD="POST">
<INPUT TYPE="hidden" NAME="-db" VALUE="database.fp3">
<INPUT TYPE="hidden" NAME="-lay" VALUE="cgi">
<INPUT TYPE="hidden" NAME="-format" VALUE="results.htm">
<INPUT TYPE="hidden" name="-MailTo" value="recipient@domain.com">
<INPUT TYPE="hidden" name="-MailCC" value="otherrecipient@domain.com">
<INPUT TYPE="hidden" name="-MailBCC" value="otherrecipient@domain.com">
Your Email Address:
<INPUT TYPE="text" name="-MailFrom" value="">
<INPUT TYPE="hidden" name="-MailSub" value="CDML Mail Solution">
<INPUT TYPE="hidden" name="-MailHost" value="smtp.domain.com">
<INPUT TYPE="hidden" name="-MailFormat" value="mail.txt">
After the opening FORM tag we list the familiar -db, -lay and-format tags. As with these tags, the majority of Mail tags are also hidden input types with the exception of MailFrom. The MailFrom tag can also be hidden but in the CDML model that accompanies this article, I chose to allow the sender to fill this out so that I could collect the senders email address as part of the solution. If the tag were hidden, the from address would have to be collected in another manner, possibly by token.
Required Alteration to Run Model
Because this solution requires targeting your SMTP server and your own email address in order to work, you will need to make the following changes to the "default.htm" page before running the solution:
1.Enter the name of your SMTP server (contact your IS department if you're unsure)
2. Enter your email address for the MailTo value
3. To test the MailCC and MailBCC, address these to yourself as well
Important Note About the Action
Mail can only be sent using a form action; links do not work. I mention this because in early projects I developed, I was sure that something was wrong with the targeted SMTP server and had several frustrating conversations with our IS person until I discovered that the MailTo doesn't work when embedded in a link. Hopefully we can all learn from my early mistake. It does state this in the CDML reference but only in terms of "process of elimination".
## END ##