We actually don’t know that, from our perspective as readers of the book. Lee does not give us any viewpoints outside of Scout’s as narrator, and what her father said about the case. DNA evidence did not exist at the time, and Mayella does show physical signs of an assault, although it seems likely from where the author wants to lead us that Mayella’s father was likely to be responsible for the physical assault, and possibly a sexual one as well. But the jurors in the story have testimony from Mayella about her rape, corroborating testimony from her father, and testimony from Tom Robinson that he was inside the house and something of a sexual nature took place. Atticus makes a great fanfare about how Tom couldn’t have used his injured right arm to strike Mayella on the left side of her face, which actually makes little sense - he could have just as easily backhanded her with his left hand. What we are left with is the narrative that Atticus creates to defend his client: The legal scholar Steven Lubet, who wrote about Finch’s case in the Michigan Law Review, said the following about Finch’s defense strategy, which he said was "to exploit a virtual catalog of misconceptions and fallacies about rape, each one calculated to heighten mistrust of the female complainant.”
Now, does Atticus have any evidence that any of that actually happened? The story doesn’t say so.
Atticus has to defend his client by creating a plausible story, implying that Mayella - described disparagingly as “a thick-bodied girl accustomed to strenuous labor” and who is implied to be the victim of incest and thus likely to share in her father’s degraded low morals, is sex-hungry, a slut who wanted to have sex with a man of another race, and thus, should be unworthy of defense in the eyes of a jury. By playing to the jury’s racial and class and sexual prejudices, this was probably one of the few defenses available and usable by an attorney defending a black man against rape in that time in the south, and one of the few defenses that historically were known to have worked with largely white and largely male juries in such cases. Atticus’s defense strategy is to try to defuse the racial issue by appealing to the jury’s class antipathies by portraying her as a “white trash slut” and swap one set of prejudices (racial) for others (economic class and sexual).
And as part of his defense, Atticus has to show that if she was sexually assaulted, she was somehow complicit in it. There is no sympathy or compassion shown for Mayella, (who certainly seems to have suffered some kind of abuse), by either Finch or by Scout, who describes her low economic status as you might expect the daughter of a comparatively wealthy attorney to do: "“Every town the size of Maycomb had families like the Ewells. No truant officers could keep their numerous offspring in school; no public health officer could free them from congenital defects, various worms, and the diseases indigenous to filthy surroundings.” Lee’s own class and sexual prejudices, and the era’s eugenics beliefs, which held that people of “bad stock” were irredeemable, were peeping out there.
Obviously, Lee’s story stacks the deck and sets Tom as the victim and Atticus as his noble hero, and clearly, Lee has constructed a story where this is the case. Given the time and setting in the story, Atticus may have had no other choice if he wanted to defend his client. The defense he uses, however, is one that most advocates rightly see as attacking the victim, i.e., the “She wanted it / she is a slut” defense. Atticus shows no remorse for having to use such a defense, however, and even seems to enjoy his ability to intimidate Mayella on the witness stand.