How to send mail in PHP mailer if two factor authentication is active


How to send mail in PHP mailer if two factor authentication is active

Create a custom app in your Gmail security settings.

  1. Log-in into Gmail with your account
  2. Navigate to https://security.google.com/settings/security/apppasswords
  3. In 'select app' choose 'custom', give it an arbitrary name and press generate
  4. It will give you 16 chars tokens.

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

Note: The link in step 2 will work only if you have 2-factor-authentication enabled.