Email sending problem

Discussion in 'PHP' started by tanvirtonu, Nov 4, 2007.

  1. #1
    I made a simple Html form which takes user mail info and message and send it.I hav made another php script for the mail to be sent. My code is given below-

     
    
    <html>
    <head>
    <title>E-mail Sending Form</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>
    
    <body>
    
    <?php
    echo "Thank You <b>$_POST[name]</b> for ur message";
    echo "<p>Your mail address is <p>$_POST[email] </p>";
    echo "<p>Your message was <p> $_POST[msg] </p>";
    //building the message.
    "$msg="Name: $_POST[name]\n";
    $msg.="E-mail $_POST[email]\n";
    $msg.="Message $_POST[msg]\n";
    //set up mail
    $subject="Tanvir's Form Submission Results";
    $recepeint="bhonest_4ever@yahoo.com";
    $mailheader="From: Tanvirs House <tanvirtonu@yahoo.com>\n";
    $mailheader.="Reply to $_POST[email]";
    //send the mai
     
    mail($recepeint,$subject,$msg,$mailheader);
    
    
    
    ?>
    </body>
    </html>
    
    
    Code (markup):
    my HTML form code is-

    
    <html>
    <head>
    <title>EmailFORM</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>
    
    <body>
    <form action="Email.php" method="post">
    <p>Your Name</p>
    <input type="text" name="name">
    <p>Mail Address</p>
    <input type="text" name="email">
    <p>Message</p>
    <textarea name="msg" cols="30" rows="10"></textarea>
    <p>
    <input type="submit" value="Send" >
    </p>
    
    </form>
    </body>
    </html>
    
    HTML:
    But when I press send button, I cant send the mail, Is says-

    " 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 D:\xampp\htdocs\Email.php on line 24 "

    WHAT IS D PROBLEM.How can I know which smtp port my ISP is using.In php.ini file the port value is 25.
    What shud I do.pls help.
     
    tanvirtonu, Nov 4, 2007 IP
  2. CountZero

    CountZero Member

    Messages:
    22
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    36
    #2
    25 port is usual port for sending mail via SMTP protocol. you shouldn't change it. what you need to change is an address of mailserver, write in php.ini address of your SMTP server instead 'localhost'
     
    CountZero, Nov 4, 2007 IP
  3. Fash

    Fash Peon

    Messages:
    37
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #3
    You have it set to localhost, but it needs to be set to whatever IP your ISP's SMTP server is in php.ini.
     
    Fash, Nov 4, 2007 IP
  4. tanvirtonu

    tanvirtonu Peon

    Messages:
    32
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Bro pls tell me if I dont know my ISPs smtp server name then which smtp server to use.
     
    tanvirtonu, Nov 6, 2007 IP
  5. garbageman

    garbageman Peon

    Messages:
    29
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Your ISP may block outgoing smtp... if so, find a mail server you can login to that will allow you to send mail, smtp.gmail.com would work if you have a gmail account
     
    garbageman, Nov 6, 2007 IP