Xampp sendmail,PHP in Windows 8

Problems with the Windows version of XAMPP, questions, comments, and anything related.

Xampp sendmail,PHP in Windows 8

Postby dyemc16 » 25. October 2015 22:32

I'm trying to make a PHP language based registration webpage for a project. everything works BUT when I send the activation code to the email (the email that is being registered), using "fake send mail", The email registered wont receive any email (I am using the same PC/Laptop opening xampp,sending mail and opening gmail). I've tried several settings on my sendmail.ini and php.ini but maybe I missed something from tutorials I found online? please help.

Here are my settings and my code.

PHP.ini :

[mail function]
Code: Select all

; SMTP = localhost
; smtp_port = 25
;sendmail_from = postmaster@localhost

sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"

;sendmail_path="C:\xampp\mailtodisk\mailtodisk.exe"


sendmail.ini :

Code: Select all

[sendmail]

smtp_server=mail.gmail.com
smtp_port=587
smtp_ssl=auto
;default_domain=mydomain.com
error_logfile=error.log
;debug_logfile=debug.log
auth_username=*********gmail.com
auth_password=*************

pop3_server=
pop3_username=
pop3_password=

force_sender=***********gmail.com
force_recipient=
hostname=



GIST of my Code:
dbconnection
Code: Select all
<?php

DEFINE('DATABASE_USER', 'root');
DEFINE('DATABASE_PASSWORD', '');
DEFINE('DATABASE_HOST', 'localhost');
DEFINE('DATABASE_NAME', 'forum');
date_default_timezone_set('UTC');

ini_set('SMTP', "mail.gmail.com");
define('EMAIL', *********@gmail.com');
DEFINE('WEBSITE_URL', 'http://localhost');

$dbc = @mysqli_connect(DATABASE_HOST, DATABASE_USER, DATABASE_PASSWORD,
    DATABASE_NAME);

if (!$dbc) {
    trigger_error('Could not connect to MySQL: ' . mysqli_connect_error());
}

?>


index
Code: Select all
<?php
include ('database_connection.php');
if (isset($_POST['formsubmitted'])) {
    $error = array();
    if (empty($_POST['name'])) {
        $error[] = 'Please Enter a name ';
    } else {
        $name = $_POST['name'];
    }
    if (empty($_POST['e-mail'])) {
        $error[] = 'Please Enter your Email ';
    } else {
        if (preg_match("/^([a-zA-Z0-9])+([a-zA-Z0-9\._-])*@([a-zA-Z0-9_-])+([a-zA-Z0-9\._-]+)+$/", $_POST['e-mail'])) {
            $Email = $_POST['e-mail'];
        } else {
             $error[] = 'Your EMail Address is invalid  ';
        }
    }
    if (empty($_POST['Password'])) {
        $error[] = 'Please Enter Your Password ';
    } else {
        $Password = $_POST['Password'];
    }

    if (empty($error))
    {
        $query_verify_email = "SELECT * FROM members  WHERE Email ='$Email'";
        $result_verify_email = mysqli_query($dbc, $query_verify_email);
        if (!$result_verify_email) {
if($result_verify_email==false)
            echo ' Database Error Occured ';
        }
        if (mysqli_num_rows($result_verify_email) == 0) {

            $activation = md5(uniqid(rand(), true));

            $query_insert_user = "INSERT INTO `members` ( `Username`, `Email`, `Password`, `Activation`) VALUES ( '$name', '$Email', '$Password', '$activation')";

            $result_insert_user = mysqli_query($dbc, $query_insert_user);
            if (!$result_insert_user) {
                echo 'Query Failed ';
            }
            if (mysqli_affected_rows($dbc) == 1) {
                $message = " To activate your account, please click on this link:\n\n";
                $message .= WEBSITE_URL . '/activate.php?email=' . urlencode($Email) . "&key=$activation";
                mail($Email, 'Registration Confirmation', $message, 'From: **********@gmail.com');

                echo '<div class="success">Thank you for
registering! A confirmation email
has been sent to '.$Email.' Please click on the Activation Link to Activate your account </div>';
            } else {
                echo '<div class="errormsgbox">You could not be registered due to a system
error. We apologize for any
inconvenience.</div>';
            }
        } else {
            echo '<div class="errormsgbox" >That email
address has already been registered.
</div>';
        }
    } else {
echo '<div class="errormsgbox"> <ol>';
        foreach ($error as $key => $values) {
            echo '   <li>'.$values.'</li>';
        }
        echo '</ol></div>';
    }
    mysqli_close($dbc);
}
?>


Hope you guys you can help me.. Thank you
dyemc16
 
Posts: 1
Joined: 25. October 2015 22:09
Operating System: Windows 8

Return to XAMPP for Windows

Who is online

Users browsing this forum: JJ_Tagy and 35 guests