PHP sending mail problem. pls help

Discussion in 'PHP' started by pavelazad, Sep 1, 2009.

  1. #1
    Hello i have a mail form page. I am getting the value from my form but my mail function is not sending the mail. can any one help me?

    the code is below:

    
    <?php
    
    $to=$_POST['hemail'];
    $from=$_POST['from'];
    $sub=$_POST['hatitle'];
    $message=$_POST['message'];
    
    mail($to,$sub,$message,$from);
    echo"<script>alert (\"You Mail has been send\");history.go(-1)</script>";
    else
    echo "<span class='red'>Failed to send the E-mail from $mail_sub to $mail_to</span>";
    
    ?>
    
    Code (markup):
     
    pavelazad, Sep 1, 2009 IP
  2. chmdznr

    chmdznr Active Member

    Messages:
    417
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    78
    #2
    is it give you an error message or what? Maybe your server mail setting?

    anyway.. your codes is erroneous.. there's an 'else' without 'if' block
     
    chmdznr, Sep 1, 2009 IP
  3. pavelazad

    pavelazad Peon

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    sorry the code is :

    <?php

    $to=$_POST['hemail'];
    $from=$_POST['from'];
    $sub=$_POST['hatitle'];
    $message=$_POST['message'];

    if (mail($to,$sub,$message,$from))
    echo"<script>alert (\"You Mail has been send\");history.go(-1)</script>";
    else
    echo "<span class='red'>Failed to send the E-mail from $mail_sub to $mail_to</span>";

    ?>

    im getting the msg "failed to send E mail." Its not sending the mail.

    Can u pls tell me wats the problem?
     
    pavelazad, Sep 1, 2009 IP
  4. chmdznr

    chmdznr Active Member

    Messages:
    417
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    78
    #4
    where did you test your script? in your localhost on in your webhost? do you have mailserver installed?
     
    chmdznr, Sep 1, 2009 IP
  5. pavelazad

    pavelazad Peon

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    i am trying it in my webhost. I am new in php i m not sure about the mailserver. how can i check and fix this problem? can u pls tell?
     
    pavelazad, Sep 1, 2009 IP
  6. chmdznr

    chmdznr Active Member

    Messages:
    417
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    78
    #6
    free webhost or paid? usually, free webhost disabled your php mail function. can you post your phpinfo() here?
     
    chmdznr, Sep 1, 2009 IP