NAME

formmail.pod - using and configuring fmail.pl


SYNOPSIS

  # Link
  .../cgi-bin/fmail.pl?form=formid
  # Configuration
  [formid form]
  fields=field1,field2,...
  email=where.to@send.to
  query=querytemplate
  done=finaltemplate
  mail=mailtemplate
  [formid formmail validation]
  field1_description=description of field1
  field1_rules=rules...
  field1_required=1
  field2_description=description of field2
  field2_rules=rules...
  # and templates, not shown here


DESCRIPTION

fmail.pl provides the basic facilities of the original formmail.pl, with the following extras:


INVOKING

In general you want to link for fmail.pl and supply a form id:

  <a href="/cgi-bin/fmail.pl?form=someform">Send us feedback</a>

You can also link without a form id:

  <a href="/cgi-bin/fmail.pl">Send us feedback</a>

which is exactly the same as:

  <a href="/cgi-bin/fmail.pl?form=default">Send us feedback</a>

If you make a modified query template, make sure you supply the form id as a hidden field:

  <input type="hidden" name="form" value="<:id:>" />

During form processing, fmail.pl accepts 2 different action values:


CONFIGURATION

Each form id refers to a form configuration section and a form validation section of the configuration file.

The configuration entries available in [form form] are:

You can also configure information used for validation and available to the <:field ...:> tag in the templates. This is from the [formid formmail validation] section.

In general each entry is the name of a field (from fields above), followed by underscore, followed by a validation configuration name, for example from_required is used to configure whether the from field is required.


TEMPLATES

fmail.pl uses three templates:

Standard BSE dynamic tags are available on the query and done templates. Standard BSE static tags are available on the mail template.

These tags are available on all three templates:

The following tags are available on the done and mail templates:

The following tags are only available on the query template:

The following tags are only available on the mail template:


ENCRYPTION

From release 0.15_08 of BSE the emails sent to the configured form address can be encrypted and optionally signed.

Warning: only the text content of the form email is encrypted, attached uploaded file will not be encrypted.

IT IS VERY IMPORTANT TO TEST A FORM IF ENCRYPTION IS ENABLED. TEST ALL CHANGES TO THE ENCRYPTION CONFIGURATION.

This is enabled by setting encrypt=1 in the [form form] configuration file section.

By default the same encryption settings as used for email will be used, but you can override these on a form basis.

Setting up GnuPG

To enable encryption of the email you must create a private key for the recipient of the email:

  someuser$ gpg --gen-key

and follow the prompts.

Find the id of the key:

  someuser$ gpg --list-keys
  /home/someuser/.gnupg/pubring.gpg
  -----------------------------
  pub  1024D/FB26DB74 2005-04-06 Joseph Bloe <someuser@example.com>
  sub  1024g/5CC8431C 2005-04-06 [expires: 2006-04-06]

and then export it:

  someuser$ gpg -a --export FB26DB74 >someuser.pubkey

You then need to take that file to the web server and import it into the public key-ring of the user that the web server software runs as:

  webuser$ gpg --import someuser.pubkey

The simplest way to enable the key for use is to sign the key, since you may not want to make the signed key usable for others, you should lsign it:

  webuser$ gpg --lsign-key FB26DB74

If you want the emails to be signed you will need to reverse this process, ie. create a private key for webuser, export it, import it to someuser.

Signing the email

If you don't want the email signed, set crypt_signing_id to empty:

  crypt_signing_id=

If you do want the encrypted email signed you will need to set the signing id and the passphrase:

  crypt_signing_id=5CC8431C
  crypt_passphrase=passphrase for private key

Troubleshooting

Problems with the encryption setup can be difficult to debug. Your first step should be to enable mail_encryption debugging:

  [debug]
  mail_encryption=1

This will dump the HOME variable used, the gpg command used, and any output from GPG to stderr, which should then show in your web server error log.

If you see problems, first try disabling signing.

If you still have problems, try running the encryption command, but without the --no-tty command, providing some input. For example, if you see:

  GPG command: gpg -aqe -r 'tony@develop-help.com' --no-tty

in the error log, try running:

  echo something | gpg -aqe -r 'someuser@example.com'

This should give you some idea of what's needed. If you see:

  Could not find a valid trust path to the key.  Let's see whether we
  can assign some missing owner trust values.
  No path leading to one of our keys found.
  1024g/5CC8431C 2005-04-06 "Joseph Bloe <someuser@example.com>"
             Fingerprint: 3F01 3589 BB4E 5D5B 9512  XXXX 063F DF74 5CC8 431C
  It is NOT certain that the key belongs to its owner.
  If you *really* know what you are doing, you may answer
  the next question with yes
  Use this key anyway?

Then you need to lsign this key, as above in Setting up GnuPG.


LOGGING TO THE DATABASE

You can configure fmail to send form data to a database by setting the sql paremeter, for example, if you have 4 form parameters, email, name, organization, notes you could use:

  sql=<<SQL
  insert form_submissions(userid,email,name,organization,notes)
     values(?,?,?,?,?)
  SQL
  sql_params={userId},email,name,organization,notes

Assuming a schema something like:

  create table form_submissions (
    id integer not null auto_increment,
    email varchar(255) not null,
    name varchar(255) not null,
    organization varchar(255) not null,
    notes text not null,
    primary key(id)
  );

You may want to disable sending the email as well:

  send_email=0

Or send the data to some other database:

  sql_dsn=dbi:DriverName:Parameters
  sql_user=database_user
  sql_password=database_password
  sql_options=AutoCommit=1

Forms with file upload fields cannot be logged to the database.


ALTERNATE EMAIL ADDRESSES

You can specify alternate email addresses for the email sent by a form with the email_select value:

  [someform form]
  email_select=state;someform emails
  email=national@example.com
  
  [someform formmail validation]
  state_htmltype=select
  state_values=nsw=NSW;qld=Qld;nt=NT
  [someform emails]
  nsw=nsw@example.com
  qld=qld@example.com
  ; nt uses default and goes to national address


AUTHOR

Tony Cook <tony@develop-help.com>


REVISION

$Revision$