I'm hoping that someone will give me a moment so I can understand how formmail works so that I can more effectively troubleshoot my problems.

Background:
I'm downloaded a very basic formmail to use on our intranet site for employees to respond to. I'm testing this on a XP Pro machine and plan to move it to the Windows 2003 server once testing is done. Our email (Exchange) is hosted remotely by ASP-one. Using IIS version 5.2

Now, excuse my ignorance but I've had no exposure to formmail before and trying to put the pieces together.

I've installed PHP 5.2.6 and running a php script from Tectite.com (see attached). I run http://testserver/fm.php?testalert=1 and it returns "Test message sent. Check your email".

Here is where is need an understanding. Because i don't see anywhere that you configure your SMTP server then i'm assuming you need to setup IIS SMTP Virtual Server. So I did this using a SMART HOST setup to ASP-ONE SMTP and then tried another ISP which we use currently for other SMTP mail. Mail goes through the queue and then into BADMAIL.
I don't know what I am missing.

Any suggestions?

HELP:$

Diane

Attachments
<?php
$FM_VERS = "8.05";      // script version

/* ex:set ts=4 sw=4 et:
 * FormMail PHP script from Tectite.com.  This script requires PHP 4 or later.
 * Copyright (c) 2001-2008 Root Software and Open Concepts Pty Ltd
 * (ABN 93 003 733 499), Melbourne, Australia.
 * This script is free for all use as described in the "Copying and Use" and
 * "Warranty and Disclaimer" sections below.
 *
 * Visit us at http://www.tectite.com/ for updates and more information.
 *
 *** If you use Tectite FormMail, please support its development and other
 *** freeware products by putting the following link on your website:
 ***  Visit www.tectite.com for free <a href="http://www.tectite.com/">form processor</a>.
 *
 * Author: Russell Robinson, 2nd October 2001
 * Last Modified: RR 14:07 Wed 15 August 2007
 * QVCS Version: $Revision: 1.4 $
 *
 * Read This First
 * ~~~~~~~~~~~~~~~
 *  This script is very well documented and quite large!  It looks daunting,
 *  but really isn't.
 *  If you have experience with PHP or other scripting languages,
 *  here's what you *need* to read:
 *      - Configuration (TARGET_EMAIL & DEF_ALERT)
 *      - Creating Forms
 *  That's it!  (Alternatively, just read the Quick Start and/or
 *  Quicker Start section below).
 *  Full configuration documentation is here:
 *      http://www.tectite.com/fmdoc/index.php
 *
 * Purpose:
 * ~~~~~~~~
 *  To accept information from an HTML form via HTTP and mail it to recipients.
 *
 * What does this PHP script do?
 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 *  On your web site, you may have one or more HTML forms that accept
 *  information from people visiting your website.  Your aim is for your
 *  website to email that information to you and/or add it to a database.
 *  FormMail performs those functions.
 *
 * Quick Start
 * ~~~~~~~~~~~
 *  1. Edit this file and set TARGET_EMAIL for your requirements (near
 *      line 235 in this file - replace "yourhost\.com" with your mail server's
 *      name).  We also strongly recommend you set DEF_ALERT (the next
 *      configuration below TARGET_EMAIL).
 *  2. Install this file as formmail.php (or other name ending in .php)
 *     on your web server.
 *  3. Create an HTML form and:
 *      - specify a hidden field called "recipients" with the email address
 *        of the person to receive the form's results.
 *      - in the your form tag set the action attribute to
 *        the formmail.php you uploaded to your web server
 *
 *  Once you have FormMail working, you may be interested in some advanced
 *  usage and features.  We have HOW-TO guides at www.tectite.com which
 *  describe many of the advanced processing you can do with FormMail.
 *      http://www.tectite.com/fmhowto/guides.php
 *
 * Quicker Start
 * ~~~~~~~~~~~~~
 *  Use the FormMail Configuration Wizard here:
 *      http://www.tectite.com/wizards/fmconf.php
 *  By answering a few questions you'll get a configured FormMail and
 *  a sample HTML form ready to upload and use on your server.
 *
 * Features
 * ~~~~~~~~
 *  For a list of features go to: http://www.tectite.com/formmailpage.php
 *
 * Security
 * ~~~~~~~~
 *  Security is the primary concern in accepting data from your website
 *  visitors.
 *  Tectite FormMail has several security features designed into it.  Note,
 *  however, it requires configuration for your particular web site.
 *
 * Configuration
 * ~~~~~~~~~~~~~
 *  To configure this script, go to the section titled "CONFIGURATION"
 *  (after reading the legal stuff below).
 *
 *  There is only one mandatory setting: TARGET_EMAIL
 *  and one strongly recommended setting: DEF_ALERT
 *
 *  Full configuration information is available here:
 *      http://www.tectite.com/fmdoc/index.php
 *
 * Creating Forms
 * ~~~~~~~~~~~~~~
 *  Go to this URL to learn how to write HTML forms for use with
 *  Tectite FormMail: http://www.tectite.com/fmdoc/creating_forms.php
 *
 * Copying and Use
 * ~~~~~~~~~~~~~~~
 *  Tectite FormMail is provided free of charge and may be freely distributed
 *  and used provided that you:
 *      1. keep this header, including copyright and comments,
 *         in place and unmodified; and,
 *      2. do not charge a fee for distributing it, without an agreement
 *         in writing with Root Software allowing you to do so; and,
 *      3. if you modify FormMail before distributing it, you clearly
 *         identify:
 *              a) who you are
 *              b) how to contact you
 *              c) what changes you have made
 *              d) why you have made those changes.
 *
 * Warranty and Disclaimer
 * ~~~~~~~~~~~~~~~~~~~~~~~
 *  Tectite FormMail is provided free-of-charge and with ABSOLUTELY NO WARRANTY.
 *  It has not been verified for use in critical applications, including,
 *  but not limited to, medicine, defense, aircraft, space exploration,
 *  or any other potentially dangerous activity.
 *
 *  By using Tectite FormMail you agree to indemnify Root Software and
 *  Open Concepts Pty Ltd, their agents, employees, directors and
 *  associated companies and businesses from any liability whatsoever.
 *
 * We still care
 * ~~~~~~~~~~~~~
 *  If you find a bug or fault in FormMail, please report it to us.
 *  We will respond to your report and make endeavours to rectify any
 *  faults you've detected as soon as possible.
 *
 *  To contact us please register on our forums at:
 *      http://www.tectite.com/vbforums/
 *  or view our contact information:
 *      http://www.tectite.com/contacts.php
 *
 * Version History
 * ~~~~~~~~~~~~~~~
 *  Near the top of this file, you'll find its version. The version
 *  line looks like this:
 *       $FM_VERS = "N.MM";     /* script version ...
 *
 *  The version history used to be located within this file.  However,
 *  starting with Version 8.00 we've moved it...
 *
 *  You can read the complete version history of FormMail on our
 *  main website here:
 *   http://www.tectite.com/fmdoc/version_history.php
 */

    //
    // Capture the current date and time, for various purposes.
    //
$lNow = time();

set_magic_quotes_runtime(0);        // disable this silly setting (usually not enabled)
ini_set('track_errors',1);          // enable $php_errormsg

$aAlertInfo = array();
$aPHPVERSION = array();

$sLangID = "";                      // the language ID
$aMessages = array();               // all FormMail messages in the appropriate
                                    // language

$bUseOldVars = IsOldVersion($aPHPVERSION);

    //
    // seed the random number generate if not version 4.2.0 or later
    //
if (!IsPHPAtLeast("4.2.0"))
    mt_srand(time());

    //
    // we set references to the appropriate arrays to handle PHP version differences
    // Session vars are selected after we start the session.
    //
if ($bUseOldVars)
{
    $aServerVars = &$HTTP_SERVER_VARS;
    $aGetVars = &$HTTP_GET_VARS;
    $aFormVars = &$HTTP_POST_VARS;
    $aFileVars = &$HTTP_POST_FILES;
    $aEnvVars = &$HTTP_ENV_VARS;
}
else
{
    $aServerVars = &$_SERVER;
    $aGetVars = &$_GET;
    $aFormVars = &$_POST;
    $aFileVars = &$_FILES;
    $aEnvVars = &$_ENV;
}
$bIsGetMethod = false;

    //
    // If the form submission was using the GET method, switch to the
    // GET vars instead of the POST vars
    //
if (isset($aServerVars["REQUEST_METHOD"]) && $aServerVars["REQUEST_METHOD"] === "GET")
{
    $bIsGetMethod = true;
    if ($bUseOldVars)
        $aFormVars = &$HTTP_GET_VARS;
    else
        $aFormVars = &$_GET;
}

if (!isset($REAL_DOCUMENT_ROOT))
    SetRealDocumentRoot();

if (isset($aServerVars['SERVER_PORT']))
    $SCHEME = ($aServerVars['SERVER_PORT'] == 80) ? "http://" : "https://";
else
    $SCHEME = "";
if (isset($aServerVars['SERVER_NAME']))
    $SERVER = $aServerVars['SERVER_NAME'];
else
    $SERVER = "";

/*****************************************************************************/
/* CONFIGURATION (do not alter this line in any way!!!)                      */
/*****************************************************************************
 * This is the *only* place where you need to modify things to use formmail.php
 * on your particular system.  This section finishes at "END OF CONFIGURATION".
 * Help for all settings can be found on our website:
 *  http://www.tectite.com/fmdoc/index.php
 *
 * Also, above each setting is a direct URL to the help information for the
 * setting.
 *****************************************************************************/

            /* Help: http://www.tectite.com/fmdoc/email_name.php */
define("EMAIL_NAME","^[-a-z0-9.]+");    // the '^' is an important security feature!

            /* Help: http://www.tectite.com/fmdoc/target_email.php */
$TARGET_EMAIL = array(EMAIL_NAME."@cogen\.com$");

            /* Help: http://www.tectite.com/fmdoc/def_alert.php */
define("DEF_ALERT","diane@cogen.com");

            /* Help: http://www.tectite.com/fmdoc/set_real_document_root.php */
$SET_REAL_DOCUMENT_ROOT = "";       // overrides the value set by SetRealDocumentRoot function

    //
    // override $REAL_DOCUMENT_ROOT from the $SET_REAL_DOCUMENT_ROOT value (if any)
    // Do not alter the following code (next 3 lines)!
    //
if (isset($SET_REAL_DOCUMENT_ROOT) && $SET_REAL_DOCUMENT_ROOT !== "")
    $REAL_DOCUMENT_ROOT = $SET_REAL_DOCUMENT_ROOT;

            /* Help: http://www.tectite.com/fmdoc/config_check.php */
$CONFIG_CHECK = array("TARGET_EMAIL");

            /* Help: http://www.tectite.com/fmdoc/at_mangle.php */
define("AT_MANGLE","BQC9Y8");

            /* Help: http://www.tectite.com/fmdoc/target_urls.php */
$TARGET_URLS = array();         // default; no URLs allowed

            /* Help: http://www.tectite.com/fmdoc/head_crlf.php */
define("HEAD_CRLF","\r\n");

            /* Help: http://www.tectite.com/fmdoc/body_lf.php */
define("BODY_LF","\r\n");       // the new default: use this for CR+LF
//define("BODY_LF","\n");       // the old default: just LF

            /* Help: http://www.tectite.com/fmdoc/from_user.php */
$F

It is possible that no from address is set. That may be the cause of the server rejecting your message. You can check the message details for any headers.

I think this may be what is confusing me... Our email server uses authenticated SMTP which within the Virtual SMTP server I configure my mailbox userID and PW. My email address in the fm.php is different then the credentials which are required for the SMTP server.

What settings should I be using within the fm.php? Should they match my SMTP server which is configured to match our local domain name or should it match my remote email credentials?

Thanks
Diane

If I may, I recommend using PHPMailer which you can find here http://phpmailer.codeworxtech.com/. This is an amazing class which I have worked with many times and you will find documentation on their website as well as examples in this downloaded zip file.

Here you will see that you actually define the smtp server in your script.

<?php

//error_reporting(E_ALL);
error_reporting(E_STRICT);

date_default_timezone_set('America/Toronto');
//date_default_timezone_set(date_default_timezone_get());

include_once('class.phpmailer.php');
//include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded

$mail             = new PHPMailer();

$body             = $mail->getFile('contents.html');
$body             = eregi_replace("[\]",'',$body);

$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host       = "mail.worxteam.com"; // SMTP server

$mail->From       = "name@yourdomain.com";
$mail->FromName   = "First Last";

$mail->Subject    = "PHPMailer Test Subject via smtp";

$mail->AltBody    = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test

$mail->MsgHTML($body);

$mail->AddAddress("whoto@otherdomain.com", "John Doe");

$mail->AddAttachment("images/phpmailer.gif");             // attachment

if(!$mail->Send()) {
  echo "Mailer Error: " . $mail->ErrorInfo;
} else {
  echo "Message sent!";
}

?>

PhPMailer is then used in place of the IIS Virtual SMTP Server?

This may be a really dumb question but like i said... I'm still trying to put the pieces together here to make sense and to make it work!!

thanks for your assistance

D

You will have to use PHPMailer for an SMTP with autentication as PHP does not let you add authentication for the basic mail() command.

I have PHPMailer up and running and sending mail. Do you have a recommendation for a FORMMAIL program to use with PHPMailer?

This article has been dead for over six months. Start a new discussion instead.