However, enabling two factor authentication on Yahoo (Settings > Account Security) stops this working.
The solution is - still within Yahoo Account Security - to add an App Specific Password
Go to Manage app passwords:
I have added an option of Gmail. This produces a long password which is then used in Gmail *instead* of the Yahoo password - this acts as two factor authentication.