The laws of this Commonwealth for the establishment and maintenance of public schools are designed to provide schools in each town or district for the benefit of the inhabitants thereof, and not for the benefit of residents in other towns or districts. It is only in a few exceptional cases, specified by statute, that the inhabitants of one town can send their children to the public schools in any other town; and, except in such cases and upon such conditions as are thus provided by law, towns have no authority to open their schools to children of the inhabitants of other towns. If they do receive children from other towns, in violation of law, they cannot maintain any action against the parents of such children for their tuition, even if there is an express contract to pay it. Such a contract, being founded upon illegality, cannot be enforced. The plaintiffs concede these general principles; but contend that this case falls within the provisions of the Gen. Sts. c. 41, § 7.*
*106It might be a sufficient answer to this claim, to say that it does not appear, by the agreed statement of facts, that the children of the defendant, who attended school in Haverhill, were between the ages of five and fifteen years. But the more satisfactory answer is, that the provisions in question do not apply to the children of parents who reside out of the Commonwealth. This section is to be construed in connection with the system of legislation of which it forms a part; and applies only to the children of parents who reside within the Commonwealth. It follows that, upon the agreed facts, the plaintiffs are not entitled to maintain this action, and there must be
Judgment for the defendant.
“ With the consent of school committees first obtained, children between the ages of five and fifteen years may attend school in cities and towns other than those in which their parents or guardians reside; but whenever a child resides in a city or town different from that of the residence of the parent or guardian, for the sole purpose of attending school there, the parent or guardian of such child shall be liable to pay to such city or town, for tuition, a sum *106equal to the average expense per scholar for such school for the period the child shall have so attended.”