Section 25. The probate court for the county where, or a district court within the judicial district of which, a minor under the age specified in the preceding section resides may, after hearing, make an order allowing the marriage of such minor, if the parents or surviving parent of such minor, or, if only one such parent resides in the commonwealth, that parent, or, if neither such parent is alive and resident thereof, or if the parent or parents qualified as aforesaid to consent are disqualified as hereinafter provided, a legal guardian with custody of the person of such minor has consented to such order. If a parent has deserted his family, or if found to be incapacitated by reason of mental illness and incapable of consent, or if found unfit under the provisions of section five of chapter two hundred and one to have custody of such minor, it shall not be necessary to obtain his consent to such order. If a parent whose consent would be required if living in the commonwealth lives outside thereof and the address of such parent is known, such notice of the proceedings shall be given him as the probate or district court may order. Said court may also after hearing make such order in the case of a person whose age is alleged to exceed that specified in the preceding section, but who is unable to produce an official record of birth, whereby the reasonable doubt of the clerk or registrar, as exercised under section thirty-five, may be removed. Upon receipt of a certified copy of such order by the clerk or registrar of the town where such minor resides, he shall receive the notice required by law and issue a certificate as in other cases.