In Summa theologiae III, q. 63, Thomas Aquinas addresses several topics pertaining to the fourth century Donatist heresy. The Donatists held that efficacy of the Christian sacraments depend on the worthiness of the minister. Thomas takes up this topic directly in Article 5 in which he asks whether the sacraments can be conferred by evil ministers. He answers that an instrument (for this is what a minister is, cf. q 62, aa. 1, 4) acts not from its own form (formal cause), but by the power of the one who moves it (efficient cause). Consequently, the virtue or vice of the minister as an instrument does not amplify or impede the efficacy of the sacrament since the effect derives from the efficient cause, i.e. Christ Himself.
In Article 8, Thomas focuses on the intent of the minister. He asks whether the minister of the sacrament must intend to confer a sacrament in question. The answer is affirmative because for Thomas an action without intention is merely an “act of a human” and not a “human act” (Summa theologiae I, a. 6). Unintentional acts occur by chance and sacraments are not conferred by chance – otherwise if a priest ever mistakenly uttered the words “this is my body” with bread in his hand, he would transubstantiate the bread!
In Article 9, Thomas asks whether the minister needs faith. The answer is negative for the same reason given in a. 5 above. Virtue and vice (faith is a virtue) do not amplify or impede the instrumental nature of the sacrament since they are accidental to it.
The most complex question comes last in Article 10: Whether the validity of a sacrament requires a good intention in the minister? By good intention, Thomas means that the minister intends to confer a sacrament for a right end. Even here, Thomas holds that evil intent on the part of the minister does not inhibit the effect of the sacrament. For example, if a priest should baptize a woman in order to fondle her, or if he should confect the Holy Eucharist so as to employ the consecrated elements in magical rites. Of course, if the priest’s wicked intention is simply to not confect the sacrament, then it obstructs the effect since intention to confer the sacrament is necessary. However, the same is not true for wicked acts posterior to the conferral of sacraments since the former (intention to baptize a person) does not depend on the latter (fondling the woman). All of these questions look back to the first article - that God alone works the interior sacramental effect.