So I've been messing with the settings in mac mail, and this is what seems to work:
For a Gmail account, in mail preferences, on the accounts tab click the account and then click on the advanced tab. Uncheck the "Use SSL" box, and then for Authentication choose "External (TLS Client Certificate)".
Then, in Avast preferences, under the "Shields" tab, click the Mail Shield "advanced" button. General should only have one box checked, the "Enable IPv6", then under SSL, add imap.gmail.com and pop.gmail.com.
The only other thing that might make a difference is to check the box in Mac Mail, under the accounts tab, under "Account Information" for "Outgoing Mail Server (SMTP)" choose Gmail, and check the "Use only this server" box.
I hope that works for you.