Section 30. Upon application by both of the parties to an intended marriage, when both parties are residents of the commonwealth or both parties are non-residents, or upon application of the party residing within the commonwealth when one of the parties is a resident and the other a non-resident, a judge of probate or a justice of a district court, or a special judge of probate and insolvency or special justice of a district court, may, after hearing such evidence as is presented, grant a certificate stating that in his opinion it is expedient that the intended marriage be solemnized without delay. Upon presentation of such a certificate, or, in extraordinary or emergency cases when the death of either party is imminent, upon the authoritative request of a minister, clergyman, priest, rabbi, authorized representative of a Spiritual Assembly of the Baha'is or attending physician, the clerk or registrar of the town where the notice of intention has been filed shall at once issue the certificate prescribed in section twenty-eight.