by Jamie Kramer.
There is a setting for this at Site administration / ▶︎ Plugins / ▶︎ Authentication / ▶︎ Manage authentication
called "allow login via email"
The availability of that setting will depend on version, it is available in later versions of Moodle, I don't remember at which version it was introduced. I know it is in Moodle 29+