The ruling is a blow to Trump administration's efforts to change how mail-in voting works ahead of November elections.