Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Please can you chack over my code - e-mail not being received

Status
Not open for further replies.

DougieMcN

Technical User
Sep 16, 2007
13
Hi, please can you have a look over my formmail and HTML code below.

The simple form should send client name and telephone number to me from the HTML form via the PERL script but I think I'm missing something.

The only obvious point I can see is I only have my e-mail address in the HTML script and not the Formmail script but I'm not sure where it would go if it is even required.

Both sets of code below and thanks in advance for your help.


FORMMAIL SCRIPT

#!/usr/bin/perl
##############################################################################
# FormMail Version 1.92 #
# Copyright 1995-2002 Matt Wright mattw@scriptarchive.com #
# Created 06/09/95 Last Modified 04/21/02 #
# Matt's Script Archive, Inc.: #
##############################################################################
# COPYRIGHT NOTICE #
# Copyright 1995-2002 Matthew M. Wright All Rights Reserved. #
# #
# FormMail may be used and modified free of charge by anyone so long as this #
# copyright notice and the comments above remain intact. By using this #
# code you agree to indemnify Matthew M. Wright from any liability that #
# might arise from its use. #
# #
# Selling the code for this program without prior written consent is #
# expressly forbidden. In other words, please ask first before you try and #
# make money off of my program. #
# #
# Obtain permission before redistributing this software over the Internet or #
# in any other medium. In all cases copyright and header must remain intact. #
##############################################################################
# ACCESS CONTROL FIX: Peter D. Thompson Yezek #
# #
##############################################################################
# Define Variables #
# Detailed Information Found In README File. #

# $mailprog defines the location of your sendmail program on your unix #
# system. The flags -i and -t should be passed to sendmail in order to #
# have it ignore single dots on a line and to read message for recipients #

$mailprog = '/usr/lib/sendmail -i -t';

# @referers allows forms to be located only on servers which are defined #
# in this field. This security fix from the last version which allowed #
# anyone on any server to use your FormMail script on their web site. #

@referers = ('mywebsite.co.uk','localhost');

# @recipients defines the e-mail addresses or domain names that e-mail can #
# be sent to. This must be filled in correctly to prevent SPAM and allow #
# valid addresses to receive e-mail. Read the documentation to find out how #
# this variable works!!! It is EXTREMELY IMPORTANT. #
@recipients = &fill_recipients('mywebsite.co.uk');

# ACCESS CONTROL FIX: Peter D. Thompson Yezek #
# @valid_ENV allows the sysadmin to define what environment variables can #
# be reported via the env_report directive. This was implemented to fix #
# the problem reported at #

@valid_ENV = ('REMOTE_HOST','REMOTE_ADDR','REMOTE_USER','HTTP_USER_AGENT');

# Done #


HTML FORM SCRIPT

<form class="webform" action=" method="post">
<input type="hidden" name="recipient" value="info@mywebsite.co.uk" />
<input type="hidden" name="subject" value="***Information Request***" />
<input type="hidden" name="redirect" value=" />
<input type="hidden" name="env_report" value="REMOTE_HOST,HTTP_USER_AGENT" />
<label>Name please:</label>
<br />
<input name="name" class="formname" type="text" size="31" maxlength="50" />
<div id="spacer">&nbsp;</div>
<label>Telephone number please:</label><br />

<input name="telnumber" class="formnumber" type="text" size="31" maxlength="50" />
<div id="spacer">&nbsp;</div>
<input name="enter" type="button" value="enter" />
</form>
 
the script you posted is normally named formmail.pl, but you have the form action pointing to iopost.pl. Is that the correct URI and the correct name of the perl script? What does happen when you run the script?

------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
Hi, following on from your last reply I have amended the code and changed the file name to FormMail.pl.

I have tried the file in the CGI-BIN and the formmail folder on my server but am no further forward.

I checked permissions in both locations.

Can anyone please have a look at both the HTML and PERL code below to see if I am missing the obvious.

Would having the redirect point straight back to my own home page cause any problems or is this quite acceptable.

Thanks again in advance.


HTML CODE

Code:
<form class="webform" action="[URL unfurl="true"]http://www.mywebsite.co.uk/cgi-bin/formmail/FormMail.pl"[/URL] method="post">
<input type="hidden" name="recipient" value="info@mywebsite.co.uk" />
<input type="hidden" name="subject" value="***Information Request***" />
<input type="hidden" name="redirect" value="[URL unfurl="true"]http://www.mywebsite.co.uk/index.html"[/URL] />
<label>Name please:</label>
<br />
<input name="name" class="formname" type="text" size="31" maxlength="50" />
<div id="spacer">&nbsp;</div>
<label>Telephone number please:</label><br />
<input name="telnumber" class="formnumber" type="text" size="31" maxlength="50" />
<div id="spacer">&nbsp;</div>
<input name="enter" type="button" value="enter" />
</form>


PERL SCRIPT

Code:
#!/usr/bin/perl
##############################################################################
# FormMail                        Version 1.92                               #
# Copyright 1995-2002 Matt Wright mattw@scriptarchive.com                    #
# Created 06/09/95                Last Modified 04/21/02                     #
# Matt's Script Archive, Inc.:    [URL unfurl="true"]http://www.scriptarchive.com/[/URL]              #
##############################################################################
# COPYRIGHT NOTICE                                                           #
# Copyright 1995-2002 Matthew M. Wright  All Rights Reserved.                #
#                                                                            #
# FormMail may be used and modified free of charge by anyone so long as this #
# copyright notice and the comments above remain intact.  By using this      #
# code you agree to indemnify Matthew M. Wright from any liability that      #
# might arise from its use.                                                  #
#                                                                            #
# Selling the code for this program without prior written consent is         #
# expressly forbidden.  In other words, please ask first before you try and  #
# make money off of my program.                                              #
#                                                                            #
# Obtain permission before redistributing this software over the Internet or #
# in any other medium. In all cases copyright and header must remain intact. #
##############################################################################
# ACCESS CONTROL FIX: Peter D. Thompson Yezek                                #
#                     [URL unfurl="true"]http://www.securityfocus.com/archive/1/62033[/URL]           #
##############################################################################
# Define Variables                                                           #
#      Detailed Information Found In README File.                            #

# $mailprog defines the location of your sendmail program on your unix       #
# system. The flags -i and -t should be passed to sendmail in order to       #
# have it ignore single dots on a line and to read message for recipients    #

$mailprog = '/usr/lib/sendmail -i -t';

# @referers allows forms to be located only on servers which are defined     #
# in this field.  This security fix from the last version which allowed      #
# anyone on any server to use your FormMail script on their web site.        #

@referers = ('mywebsite.co.uk','[URL unfurl="true"]www.mywebsite.co.uk');[/URL]

# @recipients defines the e-mail addresses or domain names that e-mail can   #
# be sent to.  This must be filled in correctly to prevent SPAM and allow    #
# valid addresses to receive e-mail.  Read the documentation to find out how #
# this variable works!!!  It is EXTREMELY IMPORTANT.                         #
@recipients = &fill_recipients('mywebsite.co.uk');

# ACCESS CONTROL FIX: Peter D. Thompson Yezek                                #
# @valid_ENV allows the sysadmin to define what environment variables can    #
# be reported via the env_report directive.  This was implemented to fix     #
# the problem reported at [URL unfurl="true"]http://www.securityfocus.com/bid/1187[/URL]              #

@valid_ENV = ('REMOTE_HOST','REMOTE_ADDR','REMOTE_USER','HTTP_USER_AGENT');

# Done                                                                       #
 
There is really no way for anyone to help you. If the path to sendmail is correct and the email is not being recieved and there are no other errors, nobody here can help because the sending of the email is not a perl issue if the path to sendmail is good. And that script has been around for years so we know the code is good if not advisable to use. Goggle for "NMS FormMail" which is a better script and replaces the one you are trying to use.

What you should do is try a very basic script just to send a test email and see if it works.

------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
OK Kevin, thanks for your advice.

Best regards.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top