In Massachusetts there is a presumption that a child born of a woman who is married, or was married in the last three hundred days before the child's birth, is the child of that woman's husband. This is a legal presumption and can be rebutted by evidence.
If you are filing a Paternity Complaint and the mother was married at the time of the child's birth, or in the last three hundred days before the child's birth, then the Court requires that you use a different form and that you include the Husband as a Defendant in the action. Usually a DNA test will be performed to confirm that the Husband is not the Father (which is typically sufficient evidence to rebut the presumption) and then the action can proceed similar to any other Paternity action.
This is apparently not the case in every state, as evidenced by a recent case in Michigan where a biological Father was denied parental rights because his child was born to a married couple, and Michigan law designated the Husband as the Father. According to this ABA article, the only way to overcome this presumption in Michigan is in a dispute between the Husband and Wife, so the Father had no standing. I tend to agree with the Father's lawyer who was quoted as claiming this ruling was "absurd."