Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Getting a contact form to work using formmail.pl with a .php file

Community Beginner ,
Oct 16, 2012 Oct 16, 2012

I need help with getting my contact form page to work.

I'm using formmail.pl with host service web.com.

Here is the url of the web site hosted with them:

www.liberocanto.org

Click to the Contact page and try and send the form and you get the error message about

@recipient.

I keep poring over the Matt's Script archive page at this url:  http://www.scriptarchive.com/readme/formmail.html

on setting up the formmail.pl to get the @recipient correct but don't know what is wrong.

Can anyone please help?

Thank you very much!

15.3K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 17, 2012 Oct 17, 2012

Can you post your code please? We cannot see your backend code from your website.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 17, 2012 Oct 17, 2012

Here is the .php code.

Below this I will paste the @recipients code that I have in the formmail.pl file.

Thanks for any your help!

.php code for contact page:

<?php

// Set email variables

$email_to = 'marguer@pacbell.net, rigoliarts@earthlink.net, deborahcar@earthlink.net';

$email_subject = 'Form submission';

// Set required fields

$required_fields = array('fullname','email','comment');

// set error messages

$error_messages = array(

          'fullname' => 'Please enter a Name to proceed.',

          'email' => 'Please enter a valid Email Address to continue.',

          'comment' => 'Please enter your Message to continue.'

);

// Set form status

$form_complete = FALSE;

// configure validation array

$validation = array();

// check form submittal

if(!empty($_POST)) {

          // Sanitise POST array

          foreach($_POST as $key => $value) $_POST[$key] = remove_email_injection(trim($value));

 

          // Loop into required fields and make sure they match our needs

          foreach($required_fields as $field) {

                    // the field has been submitted?

                    if(!array_key_exists($field, $_POST)) array_push($validation, $field);

 

                    // check there is information in the field?

                    if($_POST[$field] == '') array_push($validation, $field);

 

                    // validate the email address supplied

                    if($field == 'email') if(!validate_email_address($_POST[$field])) array_push($validation, $field);

          }

 

          // basic validation result

          if(count($validation) == 0) {

                    // Prepare our content string

                    $email_content = 'Libero Canto Website Comment: ' . "\n\n";

 

                    // simple email content

                    foreach($_POST as $key => $value) {

                              if($key != 'submit') $email_content .= $key . ': ' . $value . "\n";

                    }

 

                    // if validation passed ok then send the email

                    mail($email_to, $email_subject, $email_content);

 

                    // Update form switch

                    $form_complete = TRUE;

          }

}

function validate_email_address($email = FALSE) {

          return (preg_match('/^[^@\s]+@([-a-z0-9]+\.)+[a-z]{2,}$/i', $email))? TRUE : FALSE;

}

function remove_email_injection($field = FALSE) {

   return (str_ireplace(array("\r", "\n", "%0a", "%0d", "Content-Type:", "bcc:","to:","cc:"), '', $field));

}

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

<title>Libero Canto Contact Form</title>

          <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

 

          <link href="contact/css/contactform.css" rel="stylesheet" type="text/css" />

   

<style type= "text/css">

#navContact  {

          color: #D0AB5B !important;

          font-style: italic;

          font-weight: normal;

          cursor: default;

}

#termsPolicy  {

          position: relative;

          height: 50px;

          width: 800px;

          left: 420px;

          font-family: Verdana, Geneva, sans-serif;

          color: #CBE5F6;

          font-size: 9px;

          top: 660px;

}

#termsPolicy a {

          text-decoration: none;

          color: #D0AB5B !important;

          font-family: Verdana, Geneva, sans-serif;

          font-size: 9px;

}

#termsPolicy a:hover {

          text-decoration: none;

          color: #FFF;

          font-family: Verdana, Geneva, sans-serif;

}

</style>

   

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/mootools/1.3.0/mootools-yui-compressed.js"></script>

       

        <script type="text/javascript" src="contact/validation/validation.js"></script>

 

          <script type="text/javascript">

var nameError = '<?php echo $error_messages['fullname']; ?>';

                    var emailError = '<?php echo $error_messages['email']; ?>';

                    var commentError = '<?php echo $error_messages['comment']; ?>';

function MM_preloadImages() { //v3.0

  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();

    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)

    if (a.indexOf("#")!=0){ d.MM_p=new Image; d.MM_p[j++].src=a;}}

}

    </script>

   

<link href="stylesheet.css" rel="stylesheet" type="text/css" />

</head>

<body>

<div id="wrapperSecondaryDIV">

  <div id="top_navDIV">

  <ul>

            <li><a href="index.html" id="navHome">Home</a></li>

    <li><a href="html/about.html"id="navAbout">About</a></li>

    <li><a href="html/princ_pract.html" id="navPrinciples">Principles & Practices</a></li>

    <li><a href="html/docu_film.html" id="navDocumentary">Documentary Film</a></li>

    <li><a href="html/lesson_workshp.html" id="navLessons">Lessons & Workshops</a></li>

    <li><a href="html/archive.html" id="navArchive">Archive</a></li>

    <li><a href="contactform.php" id="navContact">Contact</a></li>

    </ul>

      

</div>

<div id="termsPolicy"><a href="html/privacy_policy.html">Privacy Policy</a>      <a href="html/terms_use.html">Terms of Use</a>      © 2012 Libero Canto Singing, LLC. All Rights Reserved

   

   

   

  </div>

<!-- InstanceBeginEditable name="mainSecondary" -->

<body onload="MM_preloadImages('contact/images/x.png')">

<div id="formWrap">

<h2>Contact Us</h2>

<div id="form">

<?php if($form_complete === FALSE): ?>

<form action="../cgi-bin/formmail.pl" method="post" id="comments_form">

          <div class="row">

    <div class="label">Your Name</div> <!-- end .label -->

    <div class="input">

    <input type="text" id="fullname" class="detail" name="fullname" value="<?php echo isset($_POST['fullname'])? $_POST['fullname'] : ''; ?>" /><?php if(in_array('fullname', $validation)): ?><span class="error"><?php echo $error_messages['fullname']; ?></span><?php endif; ?>

   

    </div> <!-- end .input -->

    <div class="context"> </div><!--end .context -->

    </div><!--end .row-->

   

    <div class="row">

    <div class="label">Your Email Address</div> <!-- end .label -->

    <div class="input">

    <input type="text" id="email" class="detail" name="email" value="<?php echo isset($_POST['email'])? $_POST['email'] : ''; ?>" /><?php if(in_array('email', $validation)): ?><span class="error"><?php echo $error_messages['email']; ?></span><?php endif; ?>

   

    </div> <!-- end .input -->

    <div class="context"> We will not share your email with anyone, and we will not send you messages ourselves unless requested.</div><!--end .context -->

    </div><!--end .row-->

   

    <div class="row">

    <div class="label">Your Message</div> <!-- end .label -->

    <div class="input2">

          <textarea id="comment" name="comment" class="mess"><?php echo isset($_POST['comment'])? $_POST['comment'] : ''; ?></textarea><?php if(in_array('comment', $validation)): ?><span class="error"><?php echo $error_messages['comment']; ?></span><?php endif; ?>

   

    </div> <!-- end .input -->

    </div><!--end .row-->

   

    <div class="submit">

             <input type="submit" id="submit" name="submit" value="Send Message" />

   

   </div> <!-- end .submit -->

  

   </form>

   <?php else: ?>

<p style="font-size:35px; font-family:'Palatino Linotype', 'Book Antiqua', Palatino, serif; color:#71C0E6; padding-left: 25px;">Thank you for your message!</p>

<p style="font-size:16px; font-style:italic; font-family:'Palatino Linotype', 'Book Antiqua', Palatino, serif; color:white; padding-left: 275px;"> You will be redirected back to our Home Page in just a moment.</p>

<script type="text/javascript">

setTimeout('ourRedirect()', 5000)

function ourRedirect() {

          location.href='index.html'

          }

</script>

<?php endif; ?>

</div> <!--end form-->

</div> <!--end formWrap-->

</body>

  <!-- InstanceEndEditable -->

<div id="footerMainDIV">Libero Canto Szamosi<span class="regmark">®</span> is the registered trademark of Edvin Szamosi.      <a href="http://www.facebook.com/" target="_blank"><img src="images/facebook_logo.png" width="24" height="24" alt="Facebook" />   </a> <a href="http://www.youtube.com/" target="_blank"><img src="images/youtube_logo.png" width="24" height="24" alt="You Tube" /></a>   Web site design by MeyeRigoli Creative Design Group</div>

<!--end of wrapperDIV here --></div>

</body>

</html>

formmail.pl code for the @recipient array:

#!/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.:    http://www.scriptarchive.com/              #

##############################################################################

# 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                                #

#                     http://www.securityfocus.com/archive/1/62033           #

##############################################################################

# 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=('www.liberocanto.org', 'liberocanto.org', 'www.liberocanto.org');

# @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 = ('^marguer@pacbell\.net', '^rigoliarts@earthlink\.net', '^deborahcar@earthlink\.net');

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Oct 17, 2012 Oct 17, 2012

You have an error in your FormMail.pl:

Did you set your @refererers correctly in the pl? It should be around line 40 of the file.

In the original, it is:

@referers = ('scriptarchive.com','72.52.156.109');

You need to edit this to your domain and ip address. Did you do this?

Jim

UPDATED: You can read the documentation on this error here:

http://www.scriptarchive.com/readme/formmail.html#recipients

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 17, 2012 Oct 17, 2012

Hi thanks for offering to help.

Here is what I have in the @referers:

@referers=('www.liberocanto.org', 'liberocanto.org', 'www.liberocanto.org');

Here is what I have in the @recipients:

@recipients = ('^marguer@pacbell\.net', '^rigoliarts@earthlink\.net', '^deborahcar@earthlink\.net');

Here is what I have in my .php file for emails:

<?php

// Set email variables

$email_to = 'marguer@pacbell.net, rigoliarts@earthlink.net, deborahcar@earthlink.net';

$email_subject = 'Form submission';

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 18, 2012 Oct 18, 2012
LATEST

Your @recepients definition is conflicting with @referers. Your defined referer domain name doesn't match the recepients you'd like to send the mail to.

According to the script's README, you should define the domain names that your formmail script is allowed to send emails to.

Read this: http://www.scriptarchive.com/readme/formmail.html#recipients

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines