Get breaking news alerts and special reports. The news and stories that matter, delivered weekday mornings.

Sanford Wallace, the self-proclaimed "spam king" who has bedeviled Web users since the dawn of the public Internet two decades ago, has been sentenced to 30 months in prison and ordered to pay hundreds of thousands of dollars in restitution for bombarding Facebook users, according to court records.

Wallace, 47 — also known as "Spamford" and the handle he preferred himself, "the Spam King" — pleaded guilty in August to electronic mail fraud and to criminal contempt of court, according to sentencing documents filed Tuesday in U.S. District Court in San Jose, California. The contempt charge was leveled against Wallace for disobeying previous orders from one of his many court cases never to access Facebook in the first place.

Judge Edward J. Davila also sentenced King to mental health treatment and five years of probation once he's released. And he barred King from possessing or using any computer without the permission of his probation order.

Byers Market Newsletter Get breaking news and insider analysis on the rapidly changing world of media and technology right to your inbox. This site is protected by recaptcha

Sanford Wallace in 1997, at his height as the world's self-proclaimed 'spam king.' AP - file

According to the 2011 indictment, Wallace — using the aliases "David Frederix" and "Laura Frederix," along with at least 1,500 fake Internet domain names (including "GayestProfile.com") — illegally obtained Facebook users' account information to lure them into clicking on a link that would download their friend lists and redirect them to other websites.

In just four days over three user sessions from November 2008 to February 2009, he flooded more than 550,000 Facebook users with more than 27 million spam messages, prosecutors said.

The contempt charge arose from Wallace's disregard of three 2009 court orders never to visit Facebook. A different federal judge issued the orders after Facebook took Wallace to court over his relentless spamming.

According to court records, the prosecution had to be reset twice along the way because two of Wallace's lawyers quit the case in 2014 — one for reasons that were explained under seal and the other because, he said, Wallace refused to cooperate or even communicate with him.

Related: The Secret Tricks That Spammers Use

The plea represents the first time Wallace has ever been convicted of a crime, but it's definitely not the first time he's been punished for spamming.

Since 1995 — when he set up a company called Cyber Promotions to flood phones with junk faxes and, later, inboxes with junk email — King has lost numerous judgments in civil cases brought not only by Facebook, but also by the Federal Trade Commission, America On-Line and MySpace.

Total damages assessed against King approach $1 billion, according to court records. It's not known how much, if any, of that money Wallace has turned over.