How to Create a Gmail App Password for PHP Mailer Configuration in 2025
![]() |
How to Create a Gmail App Password for PHP Mailer Configuration in 2025 |
If you're using PHP Mailer for sending emails through Gmail, you will need to create an App Password to maintain a high level of security. This step-by-step guide will walk you through the process of setting up a Gmail app password in 2025.
Step 1: Enable Two-Step Verification
Before you can create an app password, you must enable two-step verification on your Google account. This extra layer of security is essential as it helps protect your account from unauthorized access.
- Go to your Google Account.
- Select 'Security' from the side menu.
- Scroll to 'Signing in to Google' and click on '2-Step Verification.'
- Follow the prompts to set up your two-step verification.
Step 2: Access App Password Settings
Once you have enabled two-step verification, you can now access the app password settings.
- Return to your Google Account.
- In the 'Security' section, navigate to 'App Passwords.'
- You may be asked to sign in again for security purposes.
Step 3: Create Your App Password
Now, you’re ready to create an app password specifically for your PHP Mailer application.
- In the App Passwords section, click on 'Select app' and choose 'Mail.'
- Then, select 'Select device' and choose the device you’re using.
- Click on 'Generate' to create your app password.
Step 4: Save Your App Password
You will be presented with a 16-character app password. This password is what you'll use in your PHP Mailer configuration.
- Copy the generated app password.
- Store it in a secure location; you will need it soon.
Step 5: Configure PHP Mailer
Now that you have your app password, you can configure it in your PHP Mailer setup. Make sure to update your SMTP settings to use this app password instead of your regular Gmail password.
$mail->isSMTP();
$mail->Host = 'smtp.gmail.com';
$mail->SMTPAuth = true;
$mail->Username = 'your-email@gmail.com';
$mail->Password = 'your-app-password'; // use the app password here
$mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;
$mail->Port = 587;
Conclusion
You have successfully created an app password for your Gmail account and configured it for PHP Mailer. This ensures secure email sending while taking advantage of Gmail's features.
Stay tuned for more tips on managing app passwords and enhancing your email security.
![]() |
How to Create a Gmail App Password for PHP Mailer Configuration in 2025 |