Results 1 to 2 of 2

Thread: Total beginner plea for help - Formmail

  1. #1
    Join Date
    Apr 2011
    Posts
    1

    Question Total beginner plea for help - Formmail

    Hi all, I am a total beginner at pretty much everything to do with Web development. I'm keen to learn though (even it if takes me a while to understand!).

    I am trying to add a simple form to a webpage that allows a visitor to fill in their name, then their email address and click on a "submit" button. This will then send a basic email with the users information to a set email address.

    I've downloaded and implemented"Formmail.php" into my website, I've created some inputs in the HTML, but for the love of all things holy I cannot get it to send email out.

    I am totally ignorant at how PHP (or any other scripting language) works, and especially ignorant at how Formmail.php works.

    I cannot even see where it is asking for any SMTP server to use to send email (is it even using one?)

    The specific error I get when clicking on the "submit" button is this:
    Warning: mail() [function.mail]: SMTP server response: 530 SMTP authentication is required. in D:\Websites\synergytraining.co.uk\formmail.php on line 224
    There was an unknown error while sending email.
    go back
    So I guess it cannot authenticate with the email address I want to send to? I'm unsure as to how to do this though. I have tried changing some of the User Config setting below to no avail - I'd really appreciate some kind soul to help me please.

    Current Formmail.php code is below.

    Kind regards in advance.



    PHP Code:
    <?php
    /**
     * PHP version 5
     */
    # Copyright (c) 2002 Eli Sand

    # PHP FormMail v2.0 20030305

    # Initialize variables
    $auth NULL;
    $deny NULL;
    $must NULL;
    $post NULL;
    $http NULL;
    $form NULL;
    $list NULL;

    # Fix for magic quotes when enabled
    if (get_magic_quotes_gpc()) {
        foreach (
    $_POST as $key => $value) {
            
    $_POST["$key"] = stripslashes($value);
        }
    }

    # Detect any Windows operating system
    if (strstr(php_uname(), 'Windows')) {
        
    $IS_WINDOWS TRUE;
    }

    # USER CONFIGURABLE SETTINGS

    # Authorized email address masks that can be used as the recipient
    $auth "*@127.0.0.1, *@localhost, *@".str_replace('www.','',$_SERVER['SERVER_NAME']);

    # Email address masks that will be rejected if in the email field
    # $deny = "nobody@*, anonymous@*, postmaster@*";

    # DO NOT EDIT ANYTHING PAST THIS POINT
    # Functions

    # Trim leading and trailing white space from array values
    function array_trim(&$value$key) {
        
    $value trim($value);
    }

    # Show an error message to the user
    function error_msg($error$required FALSE) {
        global 
    $post;

        if (!empty(
    $post['missing_fields_redirect']) && $required) {
            
    header('Location: ' $post['missing_fields_redirect']);
        }
        elseif (!empty(
    $post['error_redirect'])) {
            
    header('Location: ' $post['error_redirect']);
        }
        else {
            echo 
    "<html>\r\n";
            echo 
    "\t<head>\r\n";
            echo 
    "\t\t<title>Form Error</title>\r\n";
            echo 
    "\t\t<style type=\"text/css\">* {font-family: \"Verdana\", \"Arial\", \"Helvetica\", monospace;}</style>\r\n";
            echo 
    "\t</head>\r\n";
            echo 
    "\t<body>\r\n";
            echo 
    "\t\t<p>${error}</p>\r\n\t\t<p><small>&laquo; <a href=\"javascript: history.back();\">go back</a></small></p>\r\n";
            echo 
    "\t</body>\r\n";
            echo 
    "</html>\r\n";
        }

        exit();
    }

    # Basic pattern matching on an entire array
    function pattern_grep($input$array) {
        foreach (
    $array as $value) {
            
    $value addcslashes($value'^.[]$()|{}\\');
            
    $value str_replace('*''.*'$value);
            
    $value str_replace('?''.?'$value);
            
    $value str_replace('+''.+'$value);

            if (
    eregi('^' $value '$'$input)) {
                return 
    TRUE;
            }
        }

        return 
    FALSE;
    }

    # Main
    # Check to make sure the info was posted
    if ($_SERVER['REQUEST_METHOD'] == 'POST') {

        
    $post = array(
            
    'recipient'            => $_POST['recipient'],
            
    'email'                => $_POST['email'],
            
    'subject'            => $_POST['subject'],
            
    'realname'            => $_POST['realname'],
            
    'required'            => $_POST['required'],
            
    'env_report'            => $_POST['env_report'],
            
    'sort'                => $_POST['sort'],
            
    'redirect'            => $_POST['redirect'],
            
    'error_redirect'        => $_POST['error_redirect'],
            
    'missing_fields_redirect'    => $_POST['missing_fields_redirect']
        );

        
    $http = array(
            
    'REMOTE_USER'            => $_SERVER['REMOTE_USER'],
            
    'REMOTE_ADDR'            => $_SERVER['REMOTE_ADDR'],
            
    'HTTP_USER_AGENT'        => $_SERVER['HTTP_USER_AGENT']
        );

        if (isset(
    $must['required'])) {
            
    $post['required']            = $must['required'] . ',' $_POST['required'];
        }
        if (isset(
    $must['env_report'])) {
            
    $post['env_report']            = $must['env_report'] . ',' $_POST['env_report'];
        }
        if (isset(
    $must['redirect'])) {
            
    $post['redirect']            = $must['redirect'];
        }
        if (isset(
    $must['error_redirect'])) {
            
    $post['error_redirect']            = $must['error_redirect'];
        }
        if (isset(
    $must['missing_fields_redirect'])) {
            
    $post['missing_fields_redirect']    = $must['missing_fields_redirect'];
        }

        if ((
    $auth explode(','$auth))) {
            
    array_walk($auth'array_trim');
        }
        if ((
    $deny explode(','$deny))) {
            
    array_walk($deny'array_trim');
        }

        if (
    $_POST['security_code'] != $_SESSION['security_code']) {
            
    error_msg("Invalid security code.");
        }
        else {
            unset(
    $_POST['security_code']);
            unset(
    $_SESSION['security_code']);
        }

        
    # Check for missing required fields
        
    if ((!empty($post['required'])) && ($list explode(','$post['required']))) {
            
    $list[] = 'recipient';
            
    $list[] = 'email';

            
    array_walk($list'array_trim');

            foreach (
    $list as $value) {
                if (!empty(
    $value) && empty($_POST["$value"])) {
                    
    error_msg("You have left a required field blank."TRUE);
                }
            }
        }

        
    # Check the email addresses submitted
        
    if (pattern_grep($post['email'], $deny)) {
            
    error_msg("You have specified a banned email address.");
        }
        if (!
    eregi('^([a-zA-Z0-9\.\_\-]+)\@((([a-zA-Z0-9\-]+)\.)+([a-zA-Z]+))$'$post['email'])) {
            
    error_msg("You have specified an invalid email address.");
        }

        
    # Check if the recipients email address is authorized
        
    if ((!empty($post['recipient'])) && ($list explode(','$post['recipient']))) {
            
    array_walk($list'array_trim');

            foreach (
    $list as $value) {
                if (!
    eregi('^([a-zA-Z0-9\.\_\-]+)\@((([a-zA-Z0-9\-]+)\.)+([a-zA-Z]+))$'$value)) {
                    
    error_msg("The recipients email address is invalid.");
                }
                if (!
    pattern_grep($value$auth)) {
                    
    error_msg("The recipients email address is unauthorized.");
                }
            }
        }
        else {
            
    error_msg("There was an unknown error while checking the recipients email address.");
        }

        
    # Sort the fields
        
    if ((!empty($post['sort'])) && ($list explode(','$post['sort']))) {
            
    array_walk($list'array_trim');

            foreach (
    $list as $value) {
                
    $form["$value"] = $_POST["$value"];
            }
        }
        else {
            
    $form $_POST;
        }

        
    # Create the message
        
    $subject = empty($post['subject']) ? "Web Reply" $post['subject'];

        foreach (
    $form as $key => $value) {
            if (!
    array_key_exists($key$post)) {
                
    $message .= "${key}${value}\r\n\r\n";
            }
        }

        
    $message .= "Submitted by: <" $post['email'] . "> on " date('l, F jS, Y @ g:i:s a (O)') . "\r\n";

        if (!empty(
    $post['env_report'])) {
            if ((
    $list explode(','$post['env_report']))) {
                
    $message .= "Sender Details:\r\n";

                
    array_walk($list'array_trim');

                foreach (
    $list as $value) {
                    if (
    array_key_exists($value$http)) {
                        
    $message .= "\t${value}: " $http["$value"] . "\r\n";
                    }
                }
            }
        }

        
    # Send out the email
        
    if (mail($post['recipient'], $subject$message"From: " $post['email'] . "\r\nReply-To: " $post['email'] . "\r\nX-Mailer: PHP FormMail")) {

            if (!empty(
    $post['redirect'])) {
                
    header('Location: ' $post['redirect']);
            }
            else {
                echo 
    "<html>\r\n";
                echo 
    "\t<head>\r\n";
                echo 
    "\t\t<title>Thank you</title>\r\n";
                echo 
    "\t\t<style type=\"text/css\">* {font-family: \"Verdana\", \"Arial\", \"Helvetica\", monospace;}</style>\r\n";
                echo 
    "\t</head>\r\n";
                echo 
    "\t<body>\r\n";
                echo 
    "\t\t<p>Thank you for filling out the form.</p>\r\n\t\t<p><small>&laquo; <a href=\"javascript: history.back();\">go back</a></small></p>\r\n";
                echo 
    "\t</body>\r\n";
                echo 
    "</html>\r\n";
            }
        }
        else 
    error_msg("There was an unknown error while sending email.");
    }
    else 
    error_msg("Invalid request method used.");

  2. #2
    Join Date
    Apr 2011
    Location
    Melbourne
    Posts
    12

    Smile Re: Total beginner plea for help - Formmail

    I think you have the wrong script or your talking about a script which is not from this website. Go to http://www.tectite.com/ and download the current version of the script then upload to your site and test.

    If you have further problems, let me know and I'll try and help you out.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Total newbie with form mail
    By BOMBOM in forum Community Support
    Replies: 1
    Last Post: 30-Dec-2007, 10:27 PM
  2. Beginner and need help please
    By EIC Jim in forum Community Support
    Replies: 0
    Last Post: 11-Jul-2007, 02:17 PM
  3. A desperate plea to a 'file uploading' question
    By jeztechs in forum Community Support
    Replies: 1
    Last Post: 03-Jun-2007, 08:19 PM
  4. Total Newbie
    By Tix in forum Community Support
    Replies: 2
    Last Post: 07-Mar-2006, 09:57 PM
  5. Sorry but I am a total novice
    By Reev in forum FormMail Subscription Support
    Replies: 1
    Last Post: 31-Jul-2004, 08:45 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •