Kmail, Gmail, 2FA, OAUTH

“less secure apps” are discontinued, but app specific passwords are still available. You’ll need to set one for kmail to get it working. For sending emails you need to set smtp.googlemail.com (instead of default gmail) as the email server and set authentication type to PLAIN. You’ll probably have to do the same for receiving messages replacing gmail with googlemail in the imap or pop server text box. For authentication type I’m using “plain text” on receiving. That’s how I managed to get kmail with gmail working on my devices.