I want to send email using php ... But it is giving an error.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • karthik baskar
    New Member
    • Sep 2010
    • 16

    I want to send email using php ... But it is giving an error.

    This is how my code looks like . Can anyone please help me out to solve this problem
    Code:
    <?php
    $to = "mail.example@gmail.com";
    $from_header = "From: mail.example@gmail.com";
    $subject="Hello test mail...";
    $contents="Content";
    mail($to, $subject, $contents, $from_header);
    header("Location: $HTTP_REFERER");
    ?>
    The error I got is
    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:\wamp\www\try \index.php on line 15
  • oranoos3000
    New Member
    • Jan 2009
    • 107

    #2
    hello
    for sending mail from a server , server must be able to sending mail or the other hand sever must be smtp server but localhost is'nt smpt server dont worry ,testing mail function on any localhost server make this warning and your code has not any error

    be successful

    Comment

    • Thew
      New Member
      • Aug 2010
      • 69

      #3
      That means your email is not right set in your INI file.

      Comment

      • karthik baskar
        New Member
        • Sep 2010
        • 16

        #4
        What should I set in the php.ini file ?

        Comment

        Working...