COPYRIGHT
TFMail
Copyright 2002 - 2004 London Perl Mongers, All rights reserved
The file MIME_Lite.pm is copyright ZeeGee Software Inc,
see the file for details.
LICENSE
This script is free software; you are free to redistribute it
and/or modify it under the same terms as Perl itself.
URL
The most up to date version of this script is available from the nms
script archive at
Below is what you submitted on {= date =}
{= name =}: {= value =}
{= END =}TFmail © 2002 London Perl Mongers
You can change these templates to anything you like, giving you full control over the look of the output. You don't have to include the {= FOREACH input_field =} directive or the {= date =} directive unless you want to. You can use "param" directives to get at the values of individual CGI parameters. The directive {= param.foo =} will output the value of the "foo" CGI parameter, if there is one. For example, if your HTML form has only two inputs, "name" and "age", then your success page template file might look like this: %% NMS html template file %%Thanks {= param.name =} for registering your age as {= param.age =}. Your results have been added to our database.
In a similar way, you can access the CGI environment variables via "env" template directives. For example: %% NMS html template file %%Thanks {= param.name =} for registering your age as {= param.age =}. Your results have been added to our database.
Note: we have logged your IP address as {= env.REMOTE_ADDR =}, and we will be reporting you to the FBI if you lied about your age. Have a nice day.
You can also use these "param" and "env" template directives in the email template, to get finer control over the body of the email. CONFIGURATION FILES TFmail reads its configuration from a configuration file. By default, that file is default.trc in whatever directory you set for CONFIG_ROOT above. If you have several forms on your site using TFmail, each will need its own configuration file. You can control TFmail's choice of configuration file via the "_config" hidden form field. For example, if you added the line: to one of your HTML forms, then TFmail would use foo.trc in the CONFIG_ROOT directory as its configuration file when processing that form. The choice of configuration file is the only thing that can be configured via a hidden form field. The first line of the configuration file has to be exactly the text: %% NMS configuration file %% Lines starting with '#' are ignored, and configuration values are set by putting the name of the configuration setting at the start of a line, followed by a ':' character, followed by the value for that setting. The value can be split over several lines. One configuration value that you must set is "recipient", the email address to which the form results should be mailed. For example, your configuration file might look like: %% NMS configuration file %% # # This is my configuration file # recipient: me@my.domain You can have several recipients set, in which case the form results will be copied to all of them: %% NMS configuration file %% # # This is my configuration file # recipient: me@my.domain, some-else@my.domain Other things that can be set in the configuration file are: email_template - The template file to use for the body of the email. Default: email success_page_template - The template file to use for the main HTML success page, displayed when the email has been sent. Default: spage sort - This sets the order in which the {= FOREACH input_field =} directive processes the CGI parameters. It can be the string 'alphabetic' for alphabetic order, or the string "order:" followed by a comma separated list of the parameter names. Default: the parameters are output in the order in which they occur in the HTTP request. print_blank_fields - If this is set to a true value then fields that the user left blank will be visited by the {= FOREACH input_field =} directive. Normally, blank fields are suppressed to save space. Default: 0 subject - The subject for the email. Default: "WWW Form Submission". Template directives can be included in the subject value, see the section on OUTPUT CUSTOMIZATION below. email_input - The name of the CGI parameter that will hold the user's email address. Used by TFmail to set the From field of the email. Default: no email_input, the mail comes from POSTMASTER. realname_input - The name of the CGI parameter that will hold the user's full name. Used by TFmail to set the comment part of the From field of the email if a valid email address was found in the email_input input. Default: none, so there will be no comment on the From address. If you list several inputs here then their values will be concatenated to make up the comment. by_submitter_by - The phrase added by the {= by_submitter =} template directive when outputting the user's email address. Default: 'by'. redirect - If this configuration value is set, then it must be a URL and TFmail will generate a redirect to that URL on success, instead of using the success page template. required - A comma separated list of the names of inputs that the user cannot leave blank. If any of these are blank, then the submission will not be accepted and 'missing_template' be displayed. Default: no fields are required. missing_template - The HTML template file used to generate the page that the user sees if they leave a required field blank. Default: missing. missing_fields_redirect - If this configuration value is set then it must be a URL and TFmail will generate a redirect to that URL instead of using a template if the user leaves a required field blank. Default: display template. confirmation_template - If this field is set then it must be the name of an email template that will be used to send a mail back to the user confirming their submission. CAUTION: since the user could give any email address (not just their own) and submit repeatedly, there is a risk that some nasty person will use this to mailbomb a third party. Only switch this on if you really need it. Template directives that depend on user input will be disabled for this template, so that this feature can't be used to send SPAM. Default: no confirmation email. confirmation_subject - The subject for the confirmation email, if it is activated by the confirmation_template directive above. confirmation_email_from - The email address that the confirmation will have as the From: address. Default is the value of POSTMASTER as configured in the TFmail program itself. logfile - The name of a file to which data will be appended for each successful run of the script. The name is relative to the LOGFILE_ROOT directory and does not include the LOGFILE_EXT file extension. Default: no logging. Note that logging is disabled unless the LOGFILE_ROOT constant in the script is set. log_template - The template file used to construct the text that gets appended to the log file if the logfile setting above is set. Default: log See WRITING TO A LOG FILE below. modify_html_files - A list of the names of one or more HTML files into which TFmail should insert text, relative to the HTMLFILE_ROOT directory and without the HTMLFILE_EXT file extension. See the section below on inserting text into HTML files. no_email - Set this to a true value to prevent the main e-mail from being sent. You might wish to do that if you're using TFmail.pl to record data to a log file and don't need it mailed as well. date_fmt - The format that the date will be displayed in. This is a string that contains a number of different 'tags'. Each tag consists of a % character followed by a letter. Each tag represents one way of displaying a particular part of the date or time. Here are some common tags: %Y - four digit year (2002) %y - two digit year (02) %m - month of the year (01 to 12) %b - short month name (Jan to Dec) %B - long month name (January to December) %d - day of the month (01 to 31) %a - short day name (Sun to Sat) %A - long day name (Sunday to Saturday) %H - hour in 24 hour clock (00 to 23) %I - hour in 12 hour clock (01 to 12) %p - AM or PM %M - minutes (00 to 59) %S - seconds (00 to 59) %Z - the name of the local timezone Default: '%A, %B %d, %Y at %H:%M:%S' bad_method_status - if this is set to 1 then TFmail will return the Status code for "Request Method Not Allowed" rather than an error page if the Request Method is not 'POST' (optionally 'GET' - see the items 'get_redirect' and 'get_template' below) you may want to use this if your server is configured to give custom error messages. The default value is 0 meaning the default error page will be displayed. bad_method_template - If this is set then the template will be used as the content when bad_method_status = 1 and the request method is invalid (see above.) get_redirect - Normally TFmail will only accept a 'POST' method however if this is set to a valid URL then it will redirect to the indicated page on a 'GET' request, you could for example use this to cause a redirection to your form if someone has bookmarked the results of a previous request. See also 'get_template' below. get_template - If this is set then it must specify a valid template that will be used when a 'GET' request is used, the template will be filled in the same way as the success page but no further action (such as sending mail or writing a log) will be taken. This might be useful when creating a multipage form for example or if you wanted to have a link to a partly prefilled form. If both this and 'get_redirect' are specified then the 'get_redirect' will take precedence. If this is set then it is possible to use the session capabilities as described in the items below. session_cookies - If this is set to 1 and get_template is set then when the templated page is sent out in response to a GET request a session is created and a Cookie is sent with the Session Id which will be checked when a POST request is sent - TFmail will abort if the session does not exist or there is no SessionID cooke. Some users may turn off cookies in their browser settings, if this is a problem to you then you might want to see session_field below. session_field - this can be set to the name of a hidden field on your templated form that will contain the session id when the form is posted. If this is set then for a GET request the template directive {= session_id =} will be available and contain the Session ID - you would want to create a field like: where you have session_field set to SessionID. address_style - This will specify the style of the address that is used in the From: address of the main mail message. The default (and the previous style before this option was added) is to create a form of "$email ($realname)", if it is set to a value of 1 then the address will be generated as "$realname <$email>". You may want to use this if you are using a mail client that takes the same address in the two perfectly valid styles to be different and you want to sort by From address, for instance. locale - This when set will determine the locale which is used when determining the names of months and days when using {= date =} template directive the default is to use the locale set on the server. A few examples of locale codes are: Catalan ca_ES Croatian hr_HR Czech cs_CZ Danish da_DK Dutc nl_NL Estonian et_EE Finnish fi_FI French fr_FR Galician gl_ES German de_DE Greek el_GR Hebrew he_IL Hungarian hu_HU Icelandic is_IS Italian it_IT Japanese ja_JP Korean ko_KR Lithuanian lt_LT Norwegian no_NO Polish pl_PL Portuguese pt_PT Romanian ro_RO Russian ru_RU Slovak sk_SK Slovenian sl_SI Spanish es_ES Swedish sv_SE Thai th_TH Turkish tr_TR This is not a complete list and your server may support a different set. recipient_input - This specifies the name of a form field that the recipient is taken from. It takes precedence over any recipient specified in the config. When this is set ALL templating that allows input from the form to be introduced into the mail is switched off and attempting to use a template for the email that does this will result in an error. You should think carefully before using this as it is only intended for a "recommend this page" type scenario and is not generally useful. no_content - If this configuration is set to 1 then no HTML output will be sent to the browser and instead a 204 status will be sent telling the browser that no content was intended to be sent and it should not update the current view. This could be useful if, for instance you are using a Flash form or you have a small subscription box on your page, on the other hand it may be confusing to the visitor of your web page as they will have no feedback that the submission was successful. block_lists - This is a space delimited list of DNSBL zones that list open proxies or exploited computers that can be used by spammers or crackers to attempt to anonymously access TFmail, if this is set and the requesting client appears in one of the lists then the request will be refused before any further action is taken - the default response status is '403 Forbidden' but this may be altered by setting the block_status configuration directive. Care should be taken in using this item as a lookup on a nonexistent or overloaded zone could block for some time. More information on DNSBL and useful zones can be found in README.dnsbl you got with TFmail. block_status - This will set the status that is returned if one of the configured block_lists has an entry for the requesting host - the default is '403 Forbidden' which is probably appropriate but you may for instance want to use '404 Not Found', or some other status that will indicate a permanently unsuccessful request. Issuing a status beginning with '2' is almost certainly not appropriate unless for some reason you want to encourage the client to make further requests in the belief that this one was successfull. blocked_template - If this is set to a valid template file (as described above) and block_lists is set then this will be displayed when the client is blocked. counter_file - If this is set to the name of a writable file then the {= counter =} directive is enabled. the first time it is referenced in a single request it will be incremented INLINE TEMPLATES If you don't want to have a separate file for each template, you can choose to put some or all of the templates directly into the configuration file instead, putting a '%' character at the start of each line. For example, rather than having the configuration file line: email_template: my_email_template ... and a separate my_email_template.trt file with the text: %% NMS email template file %% This is the email. remote address: {= env.REMOTE_ADDR =} user agent: {= env.HTTP_USER_AGENT =} referer: {= env.HTTP_REFERER =} The name they entered was: {= param.name =} ... you could just have the block: email_template: %This is the email. % %remote address: {= env.REMOTE_ADDR =} %user agent: {= env.HTTP_USER_AGENT =} %referer: {= env.HTTP_REFERER =} % %The name they entered was: {= param.name =} ... in the configuration file. You can do this for any of the configuration variables listed above that expect a template file as a value. Note that you must leave out the %% NMS ???? template file %% line when using an inline template like this. WRITING TO A LOG FILE If you want to keep your log files in /usr/local/tfmail/logs, then you would set LOGFILE_ROOT to '/usr/local/tfmail/logs', and you might add the following lines to your .trc file: logfile: foo log_template: %{= date =}|{= env.REMOTE_ADDR =}|{= param.email =} One problem with log files done this way is that the values input by the user can contain '|' and newline characters, so it's possible for a malicious user to mess up your log files. However, TFmail will change tag-like constructs such as "Thank you for visiting our pages. We would love it if you would Add to this guestbook we are keeping!
Fill in the blanks below to add to our guestbook.