I had a lot of problems with Gmail on my Mac some time ago and, after searching forums for the answer, found that I needed to turn off "store drafts on server." After I did that it was fine. You might try checking that out. In addition there are some issues with two-factor authentication with Gmail that you might need to resolve.
And as I mentioned above, I think there is an issue with security between Apple Mail and Yahoo. Here's the message I received from Yahoo on my "recovery" email for my wife's Yahoo account after I deleted her Yahoo account and then tried to set it up "manually on her iPhone:"
"Your account is currently not enabled to sign in from apps that do not meet modern security standards (ex. Older versions of mail and calendar apps such as Outlook). As a result, we prevented a sign in to your Yahoo account.
We strongly recommend that you switch to Yahoo's apps such as Yahoo Mail on desktop and mobile and remove your account from all other less secure apps.
If you still want to use an app that uses less secure sign in, go to https://login.yahoo.com/account/security#other-apps and turn on "Allow apps that use less secure sign in". This is not recommended and may leave your account more vulnerable to compromise. To learn more, please visit our help page: https://help.yahoo.com/kb/SLN27791.html."