#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2004
    Posts
    10
    Rep Power
    0

    Emails from php on IIS.


    I have a php script called from an html page which writes to an SQL database and then should send an email.

    Trying to test it on my localhost before uploading to my web host I find I can't get it to work.

    It writes to the database (mysql locally) okay but then hangs and eventually times out and I can get no screen output to trouble shoot it. The html calling page is on the screen and just stays there.

    I have IIS 5.1

    Here is the php script. Can anyone help with any advice as to what I could do to get it all working?

    <?
    // mail it
    $mailto = 'abrogard@yahoo.com' ;
    $subject = " Feedback Form" ;
    $webmasteraddress = "webmaster@website.com";
    $webmastername = "webmaster";
    $formurl = "feedback.html" ;
    $errorurl = "error.html" ;
    $thankyouurl = "thankyou.html" ;
    $uself = 0;
    $headersep = (!isset( $uself ) || ($uself == 0)) ? "\r\n" : "\n" ;
    $username = $_POST['username'] ;
    $firstname = $_POST['firstname'] ;
    $email = $_POST['email'] ;
    $comments = $_POST['comments'] ;
    $secondname = $_POST['secondname'] ;
    $country = $_POST['country'] ;
    $phone = $_POST['phone'] ;
    $IP = $_SERVER["REMOTE_ADDR"];
    $findme = "jonn";
    $blacklisted = "No";
    $pos = strpos($username, $findme);
    if($pos !== false){$blacklisted = "Yes";}

    if( $blacklisted != "Yes") {
    // do write to database now---------------------------
    // $link = mysql_connect("localhost", "hostusername", "hostpassword") or die("Could not

    connect : " . mysql_error());
    $link = mysql_connect("localhost", "root", "localpassword") or die("Could not connect :

    " . mysql_error());
    print "Connected successfully<p>";
    //$DB = "mail_incoming";
    $DB = "mail_pkguest";

    $table = "clients";
    mysql_select_db($DB) or die ("Database $DB not select.." . mysql_error());
    print "Successfully selected the Database: $DB ";
    $query = "INSERT INTO $table

    (username,firstname,secondname,email,country,phone,comments,IP) values

    ('$username','$firstname','$secondname','$email','$country','$phone','$comments','$IP')";
    if ( ! mysql_query( $query, $link) )
    die ( "MySQL error.....<p>" .mysql_error() );
    print "<p>Successfully added data to table : $table";
    //------------------------------------------------------
    }


    //--------------------------------------------

    $http_referrer = getenv( "HTTP_REFERER" );
    if (!isset($_POST['email'])) {
    header( "Location: $formurl" );
    echo "Exit on http_referer";
    exit ;
    }

    //if (empty($name) || empty($email) || empty($comments)) {
    // header( "Location: $errorurl" );
    // exit ;
    //}
    if ( ereg( "[\r\n]", $username ) || ereg( "[\r\n]", $email ) ) {
    header( "Location: $errorurl" );
    exit ;
    }


    if (get_magic_quotes_gpc()) {
    $comments = stripslashes( $comments );
    }
    $messageproper =
    "This message was sent from:\n" .
    "$http_referrer\n" .
    "------------------------------------------------------------\n" .
    "UserName of sender: $username\n" .
    "Firstname of sender: $firstname\n" .
    "Secondname of sender : $secondname\n" .
    "Country of sender : $country\n" .
    "Phone number of sender: $phone\n" .
    "Email of sender: $email\n" .
    "IP of sender: $IP\n" .
    "Blacklisted: $blacklisted\n" .
    "------------------------- COMMENTS -------------------------\n\n" .
    $comments .
    "\n\n------------------------------------------------------------\n" ;

    mail($mailto, $subject, $messageproper, "From: \"$username\" <$email>" . $headersep .

    "Reply-To: \"$username\" <$email>" . $headersep . "X-Mailer: chfeedback.php 2.07" );
    header( "Location: $thankyouurl" );

    print "about to exit routine";
    exit ;

    ?>


    p.s. IIS manager shows the default SMTP service with one domain called 'asus' - the name of my machine.
  2. #2
  3. No Profile Picture
    Grumpier old Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jun 2003
    Posts
    14,443
    Rep Power
    4539
    Did you get this issue resolved? There is a setting for SMTP in your php.ini file for one guess.
    ======
    Doug G
    ======
    Bartender to Rene Descartes "have another beer?" Descartes: "I think not" and he vanished.
    --Alfred Bester

IMN logo majestic logo threadwatch logo seochat tools logo