So I made the adjustments to my alarm.py and gave it a go with my weather station reporting when the temperature is over 70f (which is everyday here in Sunny Florida!) In both cases using port 587 and 465 with my Google Workspace account (aka paid gmail for a domain), I received alerts from my machine. So it is most likely not a port problem.
So what I recommend is going on the terminal and checking to see if you can connect directly to
smtp.gmail.com at ports 465 and 587 on the machine that is hosting your weewx instance:
telnet
smtp.gmail.com 587
If it responds back with a 200, then type in HELO <yourdomain> and see if it responds back.
If you get a connection refused, then you are having problems connecting to that server. I would diagnosis and research the problem on your end further (eg firewalls, gmail security setup, etc.)
Doug