SMTP Configuration for PHPMailer
This guide explains how to configure and set up SMTP details in the following files:
1. admin/manage-cargo.php
2. users/payment-gateway.php
Prerequisites
Ensure you have the following:
A valid Gmail account.
Your Gmail password or App Passkey (recommended for security).
Access to the mentioned files in your project.
Instructions
1. Locate the Configuration Code:
o Open the admin/manage-cargo.php and users/payment-gateway.php files in a code
editor.
2. Add Your Email Credentials:
o Replace the placeholder values in the following code snippet with your Gmail email
ID and passkey:
o $mail->SMTPDebug = 0; // Disable verbose debug output
o $mail->isSMTP(); // Use SMTP
o $mail->Host = 'smtp.gmail.com'; // Gmail SMTP server
o $mail->SMTPAuth = true; // Enable SMTP authentication
o $mail->Username = 'your-email@gmail.com'; // Your email ID
o $mail->Password = 'your-gmail-passkey'; // Your Gmail App Passkey
o $mail->SMTPSecure = 'tls'; // Use TLS encryption
o $mail->Port = 587; // Gmail SMTP port
o // Sender Information
$mail->setFrom('your-email@gmail.com', 'Your Name');
o Replace your-email@gmail.com with your Gmail email ID.
o Replace your-gmail-passkey with your Gmail App Passkey.
3. Save the Changes:
o After updating the credentials, save the files.
Gmail App Passkey Setup
For security, it's recommended to use an App Passkey instead of your Gmail password. To generate
an App Passkey:
1. Go to Google Account Security.
2. Under "Signing in to Google," enable 2-Step Verification.
3. Click "App Passwords" and generate a passkey for your application.
4. Use the generated passkey in the $mail->Password field.
Important Notes
Do not share your credentials publicly.
Ensure the files are not publicly accessible to prevent unauthorized access.
If testing on localhost, make sure to allow less secure apps in your Gmail settings (not
recommended for production).
Ensure the server can connect to Gmail's SMTP (smtp.gmail.com) and port 587 is open.
Troubleshooting
If you encounter issues:
Verify your credentials.
Ensure your Gmail account has access to SMTP services.
Check for firewall or network restrictions blocking SMTP connections.