How to configure XAMPP so that i can use the mail() function

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • reymarkbacon
    New Member
    • Jun 2012
    • 2

    How to configure XAMPP so that i can use the mail() function

    i am trying to use the mail() function in PHP using these files i have downloaded in the internet.
    I have this error:
    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:\xampp\htdocs \mail\signup_ac .php on line 39
    Cannot send Confirmation link to your e-mail address

    the source code for signup_ac.php:
    Code:
    <?php
    
    include('config.php');
    
    // table name 
    $tbl_name=temp_members_db;
    
    // Random confirmation code 
    $confirm_code=md5(uniqid(rand())); 
    
    // values sent from form 
    $name=$_POST['name'];
    $email=$_POST['email'];
    $country=$_POST['country'];
    
    // Insert data into database 
    $sql="INSERT INTO $tbl_name(confirm_code, name, email, password, country)VALUES('$confirm_code', '$name', '$email', '$password', '$country')";
    $result=mysql_query($sql);
    
    // if suceesfully inserted data into database, send confirmation link to email 
    if($result){
    // ---------------- SEND MAIL FORM ----------------
    
    // send e-mail to ...
    $to=$email;
    
    // Your subject
    $subject="Your confirmation link here";
    
    // From
    $header="from: your name <your email>";
    
    // Your message
    $message="Your Comfirmation link \r\n";
    $message.="Click on this link to activate your account \r\n";
    $message.="http://www.yourweb.com/confirmation.php?passkey=$confirm_code";
    
    // send email
    $sentmail = mail($to,$subject,$message,$header);
    }
    
    // if not found 
    else {
    echo "Not found your email in our database";
    }
    
    // if your email succesfully sent
    if($sentmail){
    echo "Your Confirmation link Has Been Sent To Your Email Address.";
    }
    else {
    echo "Cannot send Confirmation link to your e-mail address";
    }
    ?>
    Last edited by Niheel; Jul 11 '12, 08:55 AM. Reason: fixed code tag
  • Luuk
    Recognized Expert Top Contributor
    • Mar 2012
    • 1043

    #2
    It means you did not setup your mailserver correctly

    here's a youtube-movie on how to do it

    Comment

    • reymarkbacon
      New Member
      • Jun 2012
      • 2

      #3
      thank you very much for that link. :)

      Comment

      Working...