mail function

Discussion in 'PHP' started by abhiN, Feb 4, 2008.

  1. #1
    Hi

    i m new to using the php.

    i want to pass the following form information to mail id
    my html is--

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>3E Solutions India</title>
    <script>

    </head>

    <body>
    <table width="100" height="54" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" id="Table_01">
    <tr>
    <td height="39" align="left" valign="top" ><strong><strong>Contact Us<br />
    </strong></h1></td>
    </tr>
    <tr>
    <td align="left" valign="top" class="tableDetail">
    <form id="form1" name="form1" method="post" action="3esmail.php" style="width:300px;">
    <p align="right">
    <label> Name:
    <input type="text" name="name" id="name" />
    </label>
    </p>
    <p align="right">Email Address:
    <label>
    <input type="text" name="email" id="email" />
    </label>
    </p>
    <p align="right">Comments:
    <label>
    <textarea name="comments" cols="20" rows="6" wrap="physical" id="comments">
    </textarea>
    </label>
    </p>
    <p align="right">
    <label>
    <input type="submit" name="button" id="button" value="Submit" />
    </label>
    </p>
    </form> <p>&nbsp;</p>
    </td>
    </tr>

    </table>


    </body>
    </html>


    and i m using php with might be incorrect as--

    3esmail.php
    <html>
    <body>

    <?php

    $name = $_POST["name"];
    $email = $_POST["email"];
    $comments = $_POST["comments"];

    $subject = "Contact Us";
    $sendto = 'about@3esolutions.com';
    $body = "comments: $comments\n";

    $body = wordwrap($body, 70);

    mail($sendto, $subject, $body);

    echo "Thanks for your Feedback";

    echo "Visit again";

    ?>


    </body>
    </html>


    and when i m submitting the form i m getting the same php as to open or save jsut like downloading any file..

    plz help for passing all data on form to mail-id..

    ok..
    byee.
     
    abhiN, Feb 4, 2008 IP
  2. powerspike

    powerspike Peon

    Messages:
    312
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #2
    that sounds like the server isn't configured correctly for php, usally if it asking you to save as for a php, you need to add in the "addType" line into the apache configuration, instructions can be found on http://au.php.net/manual/en/install.unix.apache2.php
     
    powerspike, Feb 5, 2008 IP
  3. abhiN

    abhiN Peon

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    thnks..

    i've changed my code to--

    <?php


    $headers = "MIME-Version: 1.0\r\n";
    $headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
    $headers .= "From: \r\n";
    $to = "Abhijeet.n@3esolutionsindia.com";
    $subject = "Request for Info";
    $body = "Test Email";


    if (mail($to,$subject,$body,$headers))
    {
    print "Success";
    }
    else
    {
    print "Failed";
    }

    ?>

    and getting error as--

    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 C:\Program Files\Apache Group\Apache2\htdocs\simplemail.php on line 13
    Failed


    in php.ini--
    [mail function]
    ; For Win32 only.
    SMTP = localhost
    smtp_port = 25

    ; For Win32 only.
    ;sendmail_from =


    why such error is coming??
    and can we use any mail addr..
    plz reply..

    ok..
     
    abhiN, Feb 5, 2008 IP
  4. powerspike

    powerspike Peon

    Messages:
    312
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #4
    By the sounds of it, there is NO mail server running on the host (which is why your getting the can't connect message). i would recomend you contact your host, and ask them what the mail server details are. You might need to relay the mail though one of their other servers.
     
    powerspike, Feb 5, 2008 IP