If the plaintiff is not a resident of the commonwealth, he shall file with his complaint a paper appointing an agent residing in the commonwealth, giving his name in full and post office address, and shall therein agree that the service of any legal process in proceedings under or growing out of the complaint shall be of the same legal effect if made on said agent as if made on the plaintiff within the commonwealth. If the agent dies, or removes from the commonwealth, the plaintiff shall forthwith make another appointment; and if he fails so to do, the court may dismiss the complaint.
Mass. Gen. Laws ch. 185, § 35