I keep getting the following error when I execute my code:
An error occurred:
Solved it by changing the SCOPES line to:
SCOPES = 'https://mail.google.com/'
Email sending works perfectly