4. Money received by a public officer, or which shall come into his possession or custody, in the performance of his official duties or in connection therewith or incidental thereto, shall be held by him in trust for the person or persons entitled thereto or for the purposes provided by law and all interest or increments which shall accrue or attach to such money while in his possession or custody shall be added to, and become a part of, the money so held and no part of such interest or increments shall be retained by such officer to his personal use or benefit, except legal fees allowed by law for receiving and disbursing the same, notwithstanding the provisions of any general or special law. An officer or other person, who violates either of the provisions contained in this section, is liable, in addition to the punishment prescribed by law for the criminal offense, to an action in behalf of the person aggrieved, in which the plaintiff is entitled to treble damages.