PHP email in Windows2008 IIS7

Discussion in 'HTML / PHP / JavaScript / CSS' started by python, Mar 11, 2008.

  1. Hi, does someone have a sample script to fire off an email from a PHP form/file in the win2008 environment? I tried the test below using my email address but it doesnt send an email. I created a 'ticket' and support said I should ask someone in the forums. PHP is running on my server, i just cant seem to send an email with it. Ultimately, i want to send an email from a php file that is called from within a Flash movie. I moved from Verio's UNIX host, and this scenario worked there, but not on Discountasp.net :(

    emailTest.php :

    <?
    mail('[email protected]','test','Ok, it works');
    ?>
     
  2. Hi, it works now. I added the php letters next to the question mark at the top, such as:

    <?php

    go figure, it wouldnt work if it didnt have those letters. I guess windows needs that as unix doesn't.
     
  3. i have a similar problem.....


    i want to be able to mail myself a form filled by the visitor of the site. i amusing code like this:


    _____________________________________________________________________________________


    <?php
    require_once "Mail.php";


    function emailHtml($from, $subject, $message, $to) {
    $host = "localhost";
    $username = "";
    $password = "";


    $headers = 'MIME-Version: 1.0' . "\r\n" . 'Content-type: text/html; charset=iso-8859-1.' . "\r\n" . 'From:' . $from . "\r\n" . 'To:' . $to . "\r\n";
    if (mail($to, $subject, $message, $headers))
    {
    echo " success.............!!!!!!!!!!";
    $URL="thanku.htm";
    header ("Location: $URL");
    } else {
    echo " failed.............!!!!!!!!!!";
    $URL="error.htm";
    header ("Location: $URL");


    }


    }


    if (!empty($_POST)) {
    extract($_POST);
    } else if (!empty($HTTP_POST_VARS)) {
    extract($HTTP_POST_VARS);
    }


    if ($customer_email==""|| $Names ==""|| $Depart_date_time==""|| $Arrive_date_time=="" || $From_port=="" || $To_port=="")
    {
    echo " failed.............!!!!!!!!!!";
    $URL="error.htm";
    header ("Location: $URL");
    }


    else
    {
    $from1 = $customer_email;
    $headers = "Errors-To: [email protected]";
    $to1 = "[email protected]";
    $subject1 = "Information Needed:";
    $body1 .= "<html>\n";
    $body1 .= "\n";
    $body1 .= "<font face=\"Arial\" color=\"#0000FF\">Name:&amp;nbsp;". $first . "&amp;nbsp;" . $last . "";
    $body1 .= "Company:&amp;nbsp;" . $company . "";
    $body1 .= "Phone:&amp;nbsp;" . $phone . "";
    $body1 .= "Email:&amp;nbsp;" . $email . "";
    $body1 .= "description:&amp;nbsp;" . $descr . "";
    $body1 .= "</b></font>";
    $body1 .= "</body>\n";
    $body1 .= "</html>\n";


    emailHtml($from1, $subject1, $body1, $to1);
    echo " success.............!!!!!!!!!!";
    $URL="thanku.htm";
    header ("Location: $URL");
    }


    ?>


    _____________________________________________________________


    it does not work. pls help.
     
  4. Bruce

    Bruce DiscountASP.NET Staff

  5. The error i get is:


    Failed opening required 'Mail.php' (include_path='.;c:\php4\pear')
     
  6. Bruce

    Bruce DiscountASP.NET Staff

    i am no php expert but I think the error means that PHP can't find mail.php file.


    Bruce

    DiscountASP.NET
    www.DiscountASP.NET
     
  7. mjp

    mjp

    Is Mail.php in the same directory as your mailing script? If not;


    require_once "Mail.php";


    will need the full path (e:\web\yoursitecom\htdocs\directory\Mail.php). Also make sure the case is correct (meaning the file is actually named Mail.php and not mail.php). I seem to recall that require_once has some weird case issues in php 4.x running on Windows. Check the documentation for require_once on the php.net site for details.

    mjp
    ---
    DiscountASP.NET
     
  8. This Mail.php is supposed to be a standard package provided by php pear.


    and shud be imported without absolute path, i believe.
     

Share This Page