Tested on a 10.10.3 Yosemite MBP. I assume that you have created the Gmail account in the first place and that an entry exists in the Accounts tab of Preferences in Mail.app.
If you have enabled two factor authentication in your Google account then you need to create an App Password at https://security.google.com/settings/security/apppasswords?pli=1. This is a critical step.
Take this password you have just generated and go to Mail.app > Preferences > Accounts > your Google IMAP Account > Password field and add that password. Copy/paste works.
If it's a problem just to send mail, from the same place click the Outgoing Mail Server dropdown > Edit SMTP Server List... tab > smtp.gmail.com > Advanced tab > Password field and populate it with the same Google App Password.
Either way, close preferences and say yes when prompted to save changes.
Now, still in Mail.app, click Window > Connection Doctor and investigate the information there. You are looking for two entries, one is Google IMAP and one is SMTP next to the Google account name you are concerned with.
If you have green lights, you are good to go. Red lights indicate a server communication problem.
You can change passwords now that you know where without deleting/creating a new account every time you have an issue.