A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: HELP: Email Form not working in PHP5!

  1. #1
    Member
    Join Date
    Jul 2004
    Location
    Melbourne, Australia
    Posts
    52

    HELP: Email Form not working in PHP5!

    Hi,

    I've been doing a lot of searching on this subject and tried a few suggestions but nothing is helping. Yes I did read the sticky in this forum. I am trying to get my flash mail form to work but the php file I am using wasn't designed for PHP5 and I am unsure how to change it. I was able to get the register_globals turned on in the php config on the server (as per one suggestion) but the forms still don't work.

    Here is the code I am using-

    PHP Code:
    <?

    // Enter your contact email address here
    $adminaddress = "[email protected]";

    // Enter the address of your website here include http://www.
    $siteaddress ="http://www.lior.com.au";

    // Enter your company name or site name here
    $sitename = "$sitename";

    /*******************************************************

    No need to change anything below unless you want to add or subtract functions or change the wording of things sent back to the flash file ...

    *******************************************************/

    // Gets the date and time from your server
    $date = date("m/d/Y H:i:s");

    // Gets the IP Address
    if ($REMOTE_ADDR == "") $ip = "no ip";
    else $ip = getHostByAddr($REMOTE_ADDR);

    //Process the form data!
    // and send the information collected in the Flash form to Your nominated email address
    if ($action != ""):
    mail("$adminaddress","$subject",
    "A visitor at $sitename has sent the following email.\n
    __________________________________________________________

    Name: $fullname
    Email: $email
    __________________________________________________________
    Subject: $subject
    __________________________________________________________
    Comments: $comments

    __________________________________________________________
    Logged Info :
    Using: $HTTP_USER_AGENT
    Hostname: $ip
    IP address: $REMOTE_ADDR
    Date/Time: $date","FROM:$adminaddress");

    //This sends a confirmation to your visitor
    mail("$email","re: $subject",
    "Hi $fullname,\n
    We have received your email. This is an automated response. Please do not reply to this email.
    Thank you for your interest in LIOR. \n
    Sincerely,
    $sitename
    $siteaddress","FROM:$adminaddress");

    //Confirmation is sent back to the Flash form that the process is complete
    $sendresult = "Thank you for contacting us. You will receive a confirmation email shortly.";
    $send_answer = "answer=";
    $send_answer .= rawurlencode($sendresult);
    echo "$send_answer";

    endif;
    ?>
    If someone could explain how I change this code to work in a PHP5 environment I would be endlessly thankful as it is really urgent.

    Many thanks,
    Jman

  2. #2
    Member
    Join Date
    Jul 2004
    Location
    Melbourne, Australia
    Posts
    52
    So...I went about trying to test if the server is allowing me to use the mail function. I created a php file with the following code-

    PHP Code:
    <?
    mail("yourname@yourdomain","test","Ok, it works");
    ?>
    I changed the email address to my email address, uploaded the file to the server and got this response when I called the file from the browser-

    HTML Code:
    Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in E:\Websites\Lior\mailtest.php on line 8
    Does this mean the server is not allowing me to use the mail function? What do I need them to do to allow me to do this?

    Any help is greatly appreciated.

    Jman

  3. #3
    Registered User
    Join Date
    Feb 2001
    Posts
    13,039
    Hi,

    as for your main script:
    all of the variables you import should be changed, like
    $_POST['subject'] instead of $subject
    Also, things like $REMOTE_ADDR also change, intp $_SERVER['REMOTE_ADDR']

    As for the mailing problem: if this is paid hosting, and there is nothing in your contract that forbids mail sending, it is probably a problem of fix or get money back. The admin SHOULD set up the php.ini so that a working mail relay is used.
    Dont let them tell you that you should use some code supplied by the host instead - they CAN do it correctly

    Musicman

Posting Permissions

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




Click Here to Expand Forum to Full Width

HTML5 Development Center