I tried my code above with my Gmail account (it’s actually a Google Apps account, but it should be identical) and it works fine for me. I even tried the wrong "From" header and also used the wrong source address at the SMTP level - both times Gmail allowed me to send email, but it seemed to calmly fix the header on exit. However, you may need to re-verify your address on your username. Also try using the full email address as the username if you are currently only using the part before @.
I also tried the wrong password and received error 535, which does not match what you see. Since I have two-factor authentication enabled, I also tried my real password instead of a specific application and still generated error 535 (but with the message “password for the application is required”).
Is it possible that your ISP has set up something that intercepts SMTP connections to Gmail? It seems unlikely that although my ISP once blocked access to Gmail on port 587, although port 465 still worked. Perhaps you could try using smtplib.SMTP_SSL on port 465 just in case and see if that gives you more joy.
You can also try sending addresses to different providers if Gmail rejects sending for this reason (for example, if another provider was included in the spam blacklist, for example). In addition, if possible, your e-mail looks like spam, try entering a code with a message subject and body that are close to a genuine email and see if that helps.
source share