IT Technical Support for Developers

Windows


PHPMailer Enable 2FA Send Mail with 2 Step Authentication

How to send mail using PHP mailer if two factor authentication?

2 Step Verification

Gmail 2 steps verification

To send emails using PHPMailer with 2-factor authentication (2FA), you'll need to generate an "App Password" or set up OAuth2. Instead of your regular password, use the App Password in PHPMailer's settings.

Steps to Create App Password

Enable 2FA: Make sure 2FA is enabled in your Google Account.

Create a custom app in your Gmail security settings.
Step 1 Click Google Apps icon (right side top near user logo)
Step 2 Click Account
Step 3 Click Security Menu from left side
Step 4 Type "App password" in the search field
Step 5 Click "App Password" Link
Step 6 Enter the App Name as PHPMailer and submit
Step 7 You will get App Password.(It will generate a token to use in the App )

This is what you'll use in PHPMailer.

Sample Code

$email = new PHPMailer(true);

$email->IsSMTP(); // Use SMTP
$email->Host= 'smtp.gmail.com'; // Sets SMTP server

$email->SMTPDebug = 0; // 2 to enable SMTP debug information
$email->Debugoutput = 'html';
$email->SMTPAuth = TRUE; // enable SMTP authentication
$email->SMTPSecure = "SSL"; //Secure conection
$email->Port = 587; // set the SMTP port
$email->SMTPOptions = array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
)
);

$email->Username = 'your_email@gmail.com'; // Your Gmail address
$email->Password = 'your_app_password'; // The App Password
$email->setFrom('your_email@gmail.com', 'Your Name');
$email->addAddress('recipient@example.com', 'Recipient Name');
$email->Subject = '2FA Test Email';
$email->Body = 'This is 2 Step Verification Mail Sent by PHPMailer.';

if ($email->send()) {
echo 'Message sent!';
} else {
echo 'Mailer Error: ' . $mail->ErrorInfo;
}

Use the token as password in combination with your full Gmail account and two factor authentication will not be required.

How to enable two factor authentication in Gmail



0x00000040, How to Fix Win 11 Printer Sharing to win 10 /win 7

Operation Could Not Be Completed Error 0x00000040 The Specified Network Name Is No Longer Available

How can I fix Printer Error 0x00000040?
Windows 11 Network Printer Sharing to Windows 10 / Windows 8 / Windows 7
It’s a common error that users face if a third-party printer driver is installed on the print server. Fortunately, you can fix this by following some simple steps.

Printer Error 0x00000040 can be fixed by following some simple steps.
What causes Operation could not be completed (error 0x00000040)?

Windows 10/11 doesn’t allow users to install a third-party printer driver on the print server. You need to change the Group Policy settings or tweak the Registry to resolve the issue. The other reasons for this error could be:

1.Point and Print Restrictions policy
2.Pending print jobs in Print Spooler
3.Printer Driver issues.
Run Printer Troubleshooter

1. Press Windows Key + I to open Settings.
2. Scroll down and select Troubleshoot > Other Troubleshooters.
3. Click on Run beside Printer.
4. Once the process is complete, restart your device to see if the printer error has been resolved.
Modify Group Policy Settings

GP Settings for 0x00000040 Kernel-mode drivers operate in kernel mode and have unlimited access to hardware and memory. But sometimes, the kernel-mode driver’s policy can malfunction due to corrupted drivers. Disable the policy and check if the error is fixed.
Disable the Point and Print using Registry Editor

1. Press the Windows key + R to open the Run dialog box.
2. Type regedit and hit Enter.
3. Navigate to the following path :HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows NT\Printers\PointAndPrint

4. right-click on InForest and select Modify.
5. Now enter the Value data as 0 and click Ok to save the changes.
6. In the same way, change the value data of Restricted and TrustedServers to 0.
7. Close the Registry Editor and restart your computer.
Update Printer driver

Update your Printer driver and see. Keeping your drivers up-to-date is very important. Although Optional Updates do update some of the drivers, some require you to download the driver manually from the manufacturer’s website.









Related Links...

Windows 11 Upgrade from Windows 10 - A Free Upgrade


Windows 11 error code 0x800f0950


Windows 10 printer sharing error 0x0000011b


Windows 10 printer sharing error 0x0000011b FIX


How do I fix Windows Update 11 error?


How to get Windows 11 without TPM 2.0


Windows 10 printer error 0x00000709


How do I fix error 0xC1900101?


Windows 11 How to Launch Task Manager


Win 11 an existing connection was forcibly closed (OS error 10054)


Upgrade from Windows 7 to Windows 10 for free