Log into gmail Click the user icon in the top-right corner and select "Manage your Google Account" Go to the security page (from the list at the left) [This is necessary for the next step, but will stop your scripts from logging into smtp with your regular password. This is sort of the point of no return. Make sure you are ready to go all the way and update all of your email-sending scripts before continuing.] Enable two-step authentication. Once two-step authentication is enabled, go back to the security page. There should now be a new section called "App Passwords". Select it. You will probably be asked to log in again. Generate a new app password. I put in "Mail" under "select app" and "Other" under "select device," but I don't think any of the information you put it matters. It will give you a 16-character app password which will be shown in yellow. Have your scripts use this password to log into smtp instead of your regular password and everything should work. It will not prompt you for 2-step verification. After doing this, my scripts seem to work. I did not have to make any other changes to the code other than substituting the app password for the original one. Hopefully it helps you too.