Use Fake SMTP Server:
-
Download Papercut SMTP:
- Visit: https://github.com/ChangemakerStudios/Papercut-SMTP/releases
- Download and run
Papercut.exe - It will listen on
localhost:25automatically
-
Configure PHP (C:\xampp\php\php.ini):
[mail function] SMTP = localhost smtp_port = 25 sendmail_from = noreply@hotelmanagement.com
-
Restart Apache in XAMPP Control Panel
-
Test: Register a user, check Papercut to see the email with verification code
-
Enable 2-Step Verification in your Gmail account
-
Generate App Password:
- Go to: https://myaccount.google.com/apppasswords
- Create app password for "Mail"
- Copy the 16-character password
-
Install PHPMailer:
cd C:\xampp\htdocs\hotel_managment composer require phpmailer/phpmailer
-
Update lib/EmailService.php - Replace
sendEmail()method:private function sendEmail($to, $subject, $htmlBody, $textBody) { require_once __DIR__ . '/../vendor/autoload.php'; $mail = new PHPMailer\PHPMailer\PHPMailer(true); try { // SMTP configuration $mail->isSMTP(); $mail->Host = 'smtp.gmail.com'; $mail->SMTPAuth = true; $mail->Username = 'your-email@gmail.com'; // <-- Change this $mail->Password = 'your-app-password'; // <-- Change this $mail->SMTPSecure = PHPMailer\PHPMailer\PHPMailer::ENCRYPTION_STARTTLS; $mail->Port = 587; // Email content $mail->setFrom($this->fromEmail, $this->fromName); $mail->addAddress($to); $mail->isHTML(true); $mail->Subject = $subject; $mail->Body = $htmlBody; $mail->AltBody = $textBody; $mail->send(); $this->logEmail($to, $subject, true); return true; } catch (Exception $e) { $this->logEmail($to, $subject, false); error_log("Email error: " . $mail->ErrorInfo); return false; } }
For quick testing without email setup:
-
Check verification codes in database:
SELECT username, email, verification_code, verification_expires FROM users WHERE is_verified = 0;
-
Manually verify a user:
UPDATE users SET is_verified = 1, verification_code = NULL, verification_expires = NULL WHERE email = 'test@example.com';
-
Check email log:
- Look at
logs/email_log.txtto see if emails were attempted
- Look at
# Open in browser:
http://localhost/hotel_managment/register.phpFill in the form:
- Username: testuser
- Email: test@example.com
- Password: password123
- Accept terms
- Complete reCAPTCHA
With Papercut SMTP:
- Open Papercut application
- See the email with 6-digit code
With Gmail:
- Check inbox for verification email
Database check:
C:\xampp\mysql\bin\mysql.exe -u root -e "USE hotel_management; SELECT username, email, verification_code, verification_expires, is_verified FROM users WHERE email='test@example.com';"# Redirected automatically to:
http://localhost/hotel_managment/verify.phpEnter the 6-digit code from email (or database)
C:\xampp\mysql\bin\mysql.exe -u root -e "USE hotel_management; SELECT username, is_verified FROM users WHERE email='test@example.com';"Should show is_verified = 1
-
Check PHP error log:
C:\xampp\apache\logs\error.log -
Check email log:
logs/email_log.txt -
Test PHP mail():
<?php $to = "test@example.com"; $subject = "Test Email"; $message = "This is a test"; $headers = "From: noreply@test.com"; if (mail($to, $subject, $message, $headers)) { echo "Email sent!"; } else { echo "Email failed!"; } ?>
- Codes expire after 15 minutes
- Click "Pošalji novi kod" (Resend code) button on verify.php
- Or register again
- Make sure you register first (creates session)
- Session variable
pending_verification_emailis required - Check
verify.phpline 122
- Email Service:
lib/EmailService.php - Register API:
api/register_user.php - Verify API:
api/verify_code.php - Resend API:
api/resend_code.php - Verify Page:
verify.php
✅ Database tables ready (verification_code, verification_expires, is_verified)
✅ Email templates created (HTML + plain text)
✅ Verification page with 6-digit input
✅ Resend functionality with rate limiting
✅ Auto-login after verification
✅ Session management
System is ready to use! Just configure email sending method.