PDA

View Full Version : Cookbook For FormMail



jim
06-08-2004, 03:01 PM
Does anybody know where there are some idiot’s ABC instructions for implementing FormMail? WestHost’s FormMail discussion in their manual is superficial. About all it does is tell you they support it -- http://manual.westhost.com/part7.html#formmail. I need simple step-by-step instructions.

In my seemingly endless combat with SPAM mail I want to fix my forms so the email address is not in the html code, but hidden from SPAM bots.

So, my essential requirement is the email address must be located in a hidden directory.

But, in addition, I would very much like to be able to take a field from the input form and use it as the “Reply to” address in the email, so when I get an email from someone using the form I can just hit Reply instead of having to cut the address from the form data and paste it into the To:

Also, I would like to be able to take a field from in the input form and use it as the “Subject” of the email.

The last two items are very desirable but not mandatory. The hidden address is mandatory.

wildjokerdesign
06-08-2004, 04:00 PM
Go ahead and grab the NMS FormMail Version here http://nms-cgi.sourceforge.net/
It comes with a readme file that is pretty good but I'll post what you want the config to look like here.

$DEBUGGING = 0;
$emulate_matts_code= 0;
$secure = 1;
$allow_empty_ref = 1;
$max_recipients = 5;
$mailprog = '/usr/sbin/sendmail -oi -t';
$postmaster = 'account@domain.com';
@referers = qw(domain.com ipnumber localhost);
@allow_mail_to = qw();
@recipients = ();
%recipient_alias = (
alias => 'account@domain.com',
);
@valid_ENV = qw(REMOTE_HOST REMOTE_ADDR REMOTE_USER HTTP_USER_AGENT);
$locale = '';
$charset = 'iso-8859-1';
$date_fmt = '%A, %B %d, %Y at %H:%M:%S';
$style = '';
$no_content = 0;
$double_spacing = 1;
$wrap_text = 0;
$wrap_style = 1;
$send_confirmation_mail = 0;

Each of these are pretty well detailed in the readme and the script itself. The %recipient_alias is how you hide the email addy. In the form itself all you have to do is use a hidden field to tell the script what alias account you want to send to..
<input type="hidden" name="recipient" value="alias" /> Ofcorse you would replace the account@domain.com with what you would want. On the @referers if you do not have a dedicated IP you could leave that out and just use the domain and localhost if you wanted to. In the above arrays and such you use spaces inbetween multiple variables. That is also explained in the readme. If I forgot anything or you get stuck let me know. I think that should get you going and that is better then trying to modify the WH version of FormMail

jim
06-08-2004, 07:58 PM
Thanks very much. Amazingly with your help everything worked on the first try. :D

It took a little head scratching to figure out how to convert FrontPage forms to use with FormMail but even that went without a hitch.

I even have it inserting the visitor's email which is a big help. Now if I can get it to use the subject the visitor provides I'll be all set

The Readme says


subject - The subject line for the email. For example:

<input type="hidden" name="subject"
value="From the feedback form" />

In this illustration they use the string literal "From the feedback form"

Do you know if there's a way to set the subject value to a form input variable?

dansroka
06-09-2004, 06:45 AM
After you use Site Manager to install FormMail, you can also just peek inside your cgi-bin/formmail directory. It comes with a ReadMe that is quite detailed.

jim
06-09-2004, 07:14 AM
After you use Site Manager to install FormMail . . .
Thanks, but I used the installation method suggested by Wild Joker, so I don't think using the Site Manager would be a good idea. Everything is installed and working. My question is whether there's a way to use something the visitor enters on the form as the message Subject.

wildjokerdesign
06-09-2004, 07:31 AM
<input type="text" name="subject">Should give you an input field the user can use. Is that what you mean? It is just a matter of making it a visible field instead of a hidden field.

jim
06-09-2004, 08:36 AM
Is that what you mean?
No. That creates a text entry box on the form. I already have such a text box on the form named "Subject." What I'm trying to do is to have the FormMail script put the text the visitor enters in that box into the subject line of the email FormMail sends to me.

It does this with a text box named "Email." It puts this in the From of the email it sends but apparently Subject doesn't work that way.

wildjokerdesign
06-09-2004, 08:53 AM
I think the problem may be that the variable is case sensitive. So you need to name the text entry box "subject" instead of "Subject". This works on my version of NMS FormMail and looking at the script there is no reason why the variable "subject" should not be used in the header of the email.

Let me know if that fixes it.

UPDATE: In the script the function that does this is
sub send_main_email_header the subject variable is turned into a FormConfig by the
sub configuration_form_fields earlier in the script.

jim
06-09-2004, 09:28 AM
I think the problem may be that the variable is case sensitive. So you need to name the text entry box "subject" instead of "Subject".
:oops: That was it

Many thanks. I think it's all working now.

The problem was, in the Readme they explain about email and realname but treat the subject entirely different. This made me assume subject wouldn't work and when it didn't I saw that as confirmation of what already seemed likely.

I assume it's explained in the Readme, but do you know off-hand how you set up two entirely different scripts for different form purposes. Do you simply use a similar script with a different filename such as FormMail2.pl?

jim

wildjokerdesign
06-09-2004, 09:43 AM
Not sure I understand your last question. What is it you would like to do? You should be able to use the same script for more then one form. You can have multiple "aliases" in the config of the script if that is what you are after.
%recipient_alias = (
'1' => 'one@your.domain',
'2' => 'two@your.domain',
'3' => 'three@your.domain',
);
Then in your the different forms you would simply set the hidden field to the aliase you want that form to send to. i.e.
<input type="hidden" name="recipient" value="2" />

If there where other things in the config part of the script that you wanted to change for a different form then yes you could simply duplicate the script with the different config and name it something else and then send the second form to that new script.

jim
06-09-2004, 09:53 AM
If there where other things in the config part of the script that you wanted to change for a different form then yes you could simply duplicate the script with the different config and name it something else and then send the second form to that new script.
That was my question.

Thanks again.