In the classroom, Douglas Le was the “cool” teacher. At 25 years old, the chemistry instructor at Gilroy High School in Northern California was only a few years older than the students he taught.

But online — away from the classroom — Le had a different identity: “Rae Pelletier.”

In a literal sense, Pelletier never existed; she amounted to a doctored image of an unspecified pornographic actress in someone’s inbox.

And yet, authorities allege, she was much, much more.

Part alter-ego, part hormone-driven teenage trap, she was a license for predation and the basis for a cunning online persona that was manufactured to trick unsuspecting boys into providing Le with explicit photos and videos on Facebook, according to the Santa Clara County District Attorney’s office.

Over the course of hundreds of interactions during her brief online life, none of the teenagers who were interacting with Pelletier realized that she was a he, and that he — of all people — was their chemistry teacher.

“We have identified nine juvenile male victims that he catfished and that he both sent nude pictures to and solicited nude pictures from,” Santa Clara Deputy District Attorney Jaron Shipp told The Washington Post. “While we’ve identified multiple child pornography victims, there’s evidence to suggest that there’s more of them.”

How many more remains uncertain, investigators say. Whatever the total number of victims, Shipp said, Le is the latest example of why young people should be wary of strangers they communicate with online.

At least five of the victims, the prosecutor noted, were students from Le’s classes, suggesting not only that he had “some sort of personal relationship” with or knowledge of the teenagers, but that “there was some planning to his approach.”

“We’re starting to see new avenues and models of creating and obtaining child pornography and exploiting children over the Internet,” Shipp told The Post. “I think catfishing is going to be one of the ways that people do it.”

Le was arrested at his home and booked into Santa Clara County Main Jail in San Jose on April 26, authorities said.

Authorities have charged Le with “possession of matter depicting a minor engaging or simulating sexual conduct, annoying or molesting a child, 9 counts of sending harmful matter to a minor, and 9 counts of communicating with a minor with the intent to commit specified crime,” according to the district attorney’s office.

Le was arraigned Monday. He did not enter a plea, according to the San Jose Mercury News.

If convicted, he could face more than eight years in prison.

Rachel Zlotziver, Gilroy Unified School District spokeswoman, said Le was placed on paid administrative leave, then resigned three days after his April arrest.

Le traded photos with his victims using Facebook’s instant messenger application — a decision that eventually led to his arrest, authorities said.

Last month, Facebook alerted the National Center for Missing and Exploited Children that an account under the name “Rae Pelletier” may have been engaged in inappropriate communication with a minor, authorities said.

The alert was forwarded to the Silicon Valley Internet Crimes Against Children Task Force, which opened an investigation, the prosecutor’s office said. On April 26, a search warrant was executed at Le’s home, where “several computers, hard drives, and other media were seized,” the prosecutor’s office said.

News of Le’s arrest that same day was widely discussed in the Gilroy High community, according to NBC affiliate KNTV.

“A really shocking moment for all the students around the school and the teachers and parents,” John Fox, a freshman at the school, told the station. “Everyone should be really concerned about it.”

“It’s definitely troubling to hear something like that if the allegations are true,” added a parent, David Gutierrez.

District Superintendent Deborah Flores said she wanted to reassure the school community that student safety remains administrators’ “highest priority.” The school made psychologists and counselors available for students who need them, Flores said in a statement emailed to The Post.

“We are working cooperatively with the San Jose Police Department to continue to ensure the safety of all students in the District as they complete their investigation into this matter,” she said.

Le’s LinkedIn profile — which is no longer available online — revealed that he graduated from the University of California at Berkeley in 2012 with a bachelor’s degree in chemical biology, KNTV reported. He received his Master of Arts in Teaching from Brown University a year later, according to the station.

Le began working at Gilroy High in 2013, KNTV reported.

At one point, the profile revealed, he served as the school’s head track and field coach.

Before he was hired, Le passed a criminal background screening that included fingerprint clearance from the Department of Justice and the FBI, the district said.

“Mr. Le’s ‘Catfishing’ did not happen at school,” a district statement said. “It happened in private homes on personal computers. In 2014, the District received a complaint that Mr. Le exchanged texts which contained inappropriate language with students. It was unprofessional and unacceptable, but there was no criminal activity and it did not rise to the level required for dismissal. The District took immediate strong disciplinary action. The District served him with a Notice of Unprofessional Conduct. There was no indication he was ‘Catfishing’ and we received no further complaints of any kind.”

The family of at least one student claims that Le engaged in inappropriate behavior long before he was flagged by Facebook administrators. The student, who is being represented by attorney Gloria Allred, has filed a lawsuit against the school district claiming that her mother reported Le’s behavior to school administrators, but that they failed to take action or protect students from the teacher.

The suit was filed recently, but the student’s mother, Celest Benn, says she reported Le’s behavior more than two years earlier, according to the court filing. Allred is also representing two other clients who have filed suits against the district saying they were sexually harassed and emotionally traumatized by Le.

Benn said her 15-year-old daughter took a chemistry class from Le. In October 2014, according to her lawsuit, Le sent the teenager what Allred described as “a number of sexually harassing text messages.”

“The explicit text messages refer to oral sex and the size of the minor’s mouth and contain an apparent threat to defecate on the girl,” the lawsuit claims.

Benn expressed shock that her alleged complaints weren’t taken seriously.

“I notified high level Gilroy Unified School District (GUSD) officials as soon I learned that my daughter had been victimized by receiving sexual texts from Mr. Le, her teacher at Gilroy High School,” she said in a statement. “Sadly, they appeared to ignore my report and allowed Mr. Le to remain as a teacher and in positions of authority at Gilroy High School with access to children.

“When any parent entrusts a child to a school, the last thing a parent would expect would be for the school district to ignore a warning that a teacher posed a danger to children,” the statement added. “This has to change.”

The lawsuits describe Le’s conduct as “oppressive, malicious and despicable” and depict a calculating predator who groomed victims by manipulating their grades, using insulting language in class, massaging their backs and exposing students to YouTube videos with profanity and sexual content. Le is also accused of telling students he had sex with their mothers and talked about the size of their genitals.

He would unfairly “assign the students who triggered his pedophilic tendencies, including Plaintiff, an ‘F’ on the progress reports,” one suit states. “In order to bring the grade up,” targeted students were required to attend “after school ‘tutoring’ sessions,” in which Le would “verbally and sexually harass, intimidate and abuse” students.

Allred told The Washington Post that her clients have yet to request a dollar amount in damages and said the figure will depend on future court proceedings, of which there could be more.

“It’s the school district that failed to perform their legally mandated duties,” she told The Post. “Much — if not all of the harm — suffered by these students could’ve been avoided.”

Her message to the district: Prepare to hear from more victims.

“There are others who have contacted us and we are continuing our investigation, and we expect that these three will not be the last lawsuits filed,” she told The Post.