Confederate President Jefferson Davis suspected a mole somewhere in his government, leaking information. It was the height of the Civil War in the early 1860s, and his army was struggling against the Union, which was getting mysteriously better and better at predicting his moves.

He became very paranoid — rightfully so — there was, indeed a mole. He just wasn’t looking in the right places.

The mole was a servant at the Confederate White House in Richmond — a freed slave with a photographic memory who, in addition to caring for his wife’s dresses, slipped the North valuable secrets from Davis’s own desk.

Her name was Mary Bowser.

Bowser’s is one of the great but infrequently told spy stories in American history — a shame, say historians and others who write about the Civil War, because it is a tale with an enduring, important lesson.

Bowser used the assumption that she was far less intelligent than her white employers against them.

“By playing to that stereotype, she becomes an intelligence agent and, therefore, proves the value of black intelligence at undermining the institution of slavery itself,” Lois Leveen, a historical novelist who based one of her books on Bowser, said while discussing the spy’s legacy in 2013 during a panel discussion at the Museum of the Confederacy in Richmond.

“This is a humdinger of a tale," said another panelist, University of Virginia historian Elizabeth Varon.

Varon detailed Bowser’s life and spy capers in her 2003 book, “Southern Lady, Yankee Spy.”

The book is primarily a biography of Elizabeth L. Van Lew, a well-known Richmond society figure and daughter of prominent slave owners. Van Lew is the second humdinger in this story. She abhorred slavery. And when the war broke out, she decided to do something about it.

Van Lew stayed in the family mansion with her mother during the war, according to Karen Abbott, the author of “Liar, Temptress, Soldier, Spy: Four Women Undercover in the Civil War.” From there, she ran a spy ring known as the Richmond Underground. Her spy methods were not particularly sophisticated, but the information her agents provided to Gen. Ulysses S. Grant — especially during the siege of Richmond — was crucial.

One of those spies was Bowser.

She was born around 1840 while her parents were enslaved by Van Lew’s family. The Van Lews had conflicted feelings about slavery, though. Elizabeth sent Bowser north to be educated during her teenage years. Later, she did missionary work in Liberia.

When she returned to Richmond, Bowser was arrested. It was illegal to return to a slave state after living in a free one.

Van Lew bailed her out. At some point, she brought Bowser into her spy network, helping her get a job as a servant at the Confederate White House.

The tradecraft was simple, Abbott said. A family friend of the Van Lews worked for a seamstress near the Confederate White House. Bowser brought the first lady’s dresses there not just when they needed work but also to send important messages to Van Lew.

The dresses held the messages. Bowser sewed them into the fabric.

This was perilous work — especially for Bowser, who probably would have been executed if she were caught.

But she was too good to be caught.

As for Van Lew, the Confederates began closing in on her in 1864, but by then the war — for Virginia and the South — was pretty much lost. When Grant’s army rolled into Richmond in 1865, Van Lew wrote in her journal, “Oh, army of my country, how glorious was your welcome!”

Grant was so pleased with her work he awarded her an official job: postmaster of Richmond.

As for Bowser, she moved to Georgia to become a teacher. And she spent the rest of her life telling the story of her time as a spy — down South and up North. Why?

“For a purpose,” Varon said. “For the purpose of saying: ‘We need our rights protected. We’re still vulnerable. The work’s not done yet.’"

How did women get abortions when they were illegal? A 1966 Post series reveals the answer

Before Roe v. Wade, women died trying to end their pregnancies

Migraines are a part of my life. This new book puts my pain in perspective.

Katherine Foxhall delivers a thorough and illuminating history of migraine

The time has come for women in politics to adopt the strategy of their opponents

For ages, the same tactics and tropes have been used against women. It’s time to turn the tables.