Any county officer who knowingly accepts or allows any deposit in the county treasury of money from any private and unofficial source is guilty of a misdemeanor, punishable by imprisonment in the county jail for not less than six months nor more than one year, or by a fine of not less than five hundred dollars ($500) and not more than five thousand dollars ($5,000), or by both that fine and imprisonment, and shall forfeit his or her office.