Minor addition to other answers.
My account have no 2-step verification, but with this solution I didn't have to log in from browser on YouTrack server machine, neither didn't have to enable less secure apps.
Config:
- SMTP Host:
smtp.gmail.com
- SMTP Port:
587
- Mail Protocol:
SMTP+TLS
- SMTP Login:
user@gmail.com
- SMTP Password:
******
(account password)
- Select SSL key:
(Nothing selected)
- From address:
YouTrack <user@domain.com>
Next:
- Try to send test email (the button right below youtrack config).
- It will fail.
- Now just login into google account from your regular browser.
- You'll get a warning about recent blocked login attempt.
- Open warning and verify the login attempt from IP of your youtrack server.
Done. Now you should be able to send test email successfully.