We next address the district court’s conclusion that actions taken within a foreclosure action do not categorically constitute debt collection within the scope of the FDCPA. We disagree and join those of our sister circuits that have concluded that a foreclosure action is an “attempt to collect a debt” as defined by the FDCPA. See Kaymark v. Bank of Am., N.A., 783 F.3d 168, 174–79 (3d Cir. 2015); Glazer v. Chase Home Fin. LLC, 704 F.3d 453, 460–65 (6th Cir. 2013); Wilson v. Draper & Goldberg, P.L.L.C., 443 F.3d 373, 376–78 (4th Cir. 2006); see also Reese v. Ellis, Painter, Ratterree & Adams, LLP, 678 F.3d 1211, 1216–18 (11th Cir. 2012) (concluding that letters threatening foreclosure are not exempt from the FDCPA because “communication related to debt collection does not become unrelated to debt collection simply because it also relates to the enforcement of a security interest”); Kaltenbach v. Richards, 464 F.3d 524, 527–29 (5th Cir. 2006) (same). . . a foreclosure proceeding does not fall outside the scope of the FDCPA solely because it is an in rem legal proceeding. As an initial matter, we have determined in previous cases that debt collectors can be subject to FDCPA liability based on actions taken in legal proceedings. See, e.g., Romea v. Heiberger & Assocs., 163 F.3d 111, 116 (2d Cir. 1998) (holding that a rent demand notice, required by New York law as a condition precedent to a summary eviction proceeding, was a “communication” to collect a debt within the meaning of the FDCPA); cf. Heintz v. Jenkins, 514 U.S. 291, 292 (1995) (concluding that “a lawyer who ‘regularly,’ through litigation, tries to collect consumer debts” is a “debt collector” under the Act (emphasis in original)). Second, to accept the defendants’ argument and exclude in rem proceedings from the scope of the FDCPA “would create an enormous loophole in the [FDCPA] immunizing any debt from coverage if that debt happened to be secured by a real property interest and foreclosure proceedings were used to collect the debt.” Wilson, 443 F.3d at 376; see also Kaymark, 783 F.3d at 179; Reese, 678 F.3d at 1217–18. We therefore find it irrelevant that a mortgage foreclosure action is an in rem action in equity rather than an in personam action at law. We conclude that mortgage foreclosure, at least under the circumstances presented here, constitutes debt collection under the FDCPA.