The Mail Demo example is a very simple example of how to use the <SENDMAIL> directive. It allows the user to send a message to a predetermined e-mail address which is set in the FDML. It allows the user to enter their own address as the address that the mail is sent from, as well as specify a subject and the text of the message.
Sending mail is a little different than most of the other operations in NetForms. The other directives create or modify files on your server, but <SENDMAIL> actually requires NetForms to make a TCP/IP connection to an SMTP server. Sending mail therefore has some unique problems.
The input form for the Mail Demo example is very simple, with fields for Name, EMail address, Subject, and so on, so it is not printed here.
Below is the Mailer.FDML file, which is more interesting:
1) <RESPONSE>"/MailDemo/Response.html"</RESPONSE> 2) <SENDMAIL "mail.yourorg.com" "email@example.com""<REPLACE EMail>"><REPLACE Subject></SENDMAIL> 3) Name: <REPLACE UserName> 4) E-Mail Address: <REPLACE EMail> 5) Phone Number: <REPLACE Phone> 6) Message: 7) <REPLACE Message>
Keep in mind that this example, unlike all of the others, will not work on your server without a couple of modifications.
Line 1 - Like the GuestBook example, the <RESPONSE> directive comes first in the FDML. The <SENDMAIL> directive is similar to the <INSERTFILE> directive in that everything after the </SENDMAIL> will be included in the resulting e-mail message.
Line 2 - The <SENDMAIL> directive is a little more complicated than other directives due to the number of parameters it requires. Here is where you must modify the example to work on your server.
The first parameter in quotes is the name of the SMTP server NetForms should use to send mail. Change this to the name of the server you would use with a normal e-mail client like Eudora.
The second parameter in quotes is the address that NetForms will send the message to. You should change this to your own e-mail address to make the demo work correctly. This can be any address you choose, including one inserted by a <REPLACE> command from a field in the user's input. These two fields are the only changes you need to make in order to get the Mail Demo example to work on your server.
The third parameter, also in quotes, is the address that the mail message is apparently from. In the example the from address is taken from a field in the user input, but it could also be fixed in the FDML.
It is important to have a valid from address on the mail you send using NetForms. Without one, messages which are incorrectly addressed or are mis-routed can float around the Internet for days or weeks wasting bandwidth of mail servers.
Lines 3-7 - Everything after the close of the <SENDMAIL> directive is sent as part of the e-mail message. It isn't apparent here, but the line breaks and other formatting in the FDML will be preserved in the final message when it is sent.
Messages that cannot be sent will end up in a file on your server named "NetForms Failed Mail Archive". If you are having trouble getting NetForms to send mail messages, you should open this file as it will contain the messages and some indication of why NetForms was unable to send them.
Copyright © 1996-8 Maxum Development Corporation
820 South Bartlett Road - Suite 104
Streamwood, IL 60107