Not done or tested myself, but ...
On the Google end, couldn't you add an addon google domain for teachers (since you want only teachers to be able to login to moodle - that right?) that uses convention for teachers addresses and extends that to something like convention@teachers.tld
In moodle then, one would restrict to @teachers.tld
Maybe:
https://support.google.com/a/answer/7502379
Like I said ... not done nor tested ... just thinking out-loud!
'SoS', Ken