A former defence worker breached the Official Secrets Act when he allegedly leaked details of a UK missile system "upon which the security of the realm partly depends", a court heard.
Simon Finch, 50, from Swansea, is accused of sharing technical details classified as "top secret".
He denies recording and disclosing secret defence information and refusing to give authorities access codes to three electronic devices.
Mr Finch is on trial at The Old Bailey.
The jury heard how the software engineer had worked for companies, including BAE Systems and QinetiQ, contracted to provide services to the Ministry of Defence, from the late 1990s until 2018.
In October 2018, it is alleged Mr Finch, of Penlan Crescent, Uplands, sent an email to eight recipients including law firms, charities, trade unions, an MP and a US citizen, containing classified information he had accessed.
It detailed operational information about the weapons system, which is still in use by the armed forces, the court heard.
An expert damage assessment found the release of the information could give "a hostile adversary of the UK... an understanding of the function" of the system and "methods of countering it", prosecutor Mark Heywood said.
He said the email outlined technical detail about systems "on which the security of the realm partly depends", that are classified as "secret and top secret".
He described how Mr Finch's health had begun to deteriorate after two alleged homophobic attacks in 2013 that he claimed had started his "downward spiral".
Mr Finch had claimed the police had refused to attend, investigate or classify the attacks as hate crimes.
As a result of the attack and the failure of the police to investigate, Mr Finch had lost the ability to leave his home or socialise, he had claimed.
And in 2016, Mr Heywood said Mr Finch had pleaded guilty to possessing an offensive weapon and a bladed article, for which he received a suspended sentence.
In the 2018 email, Mr Finch made claims of mistreatment that "amounted to torture" at the hands of the police.
The email had stated that his employer had become aware of the issue but had "totally ignored" his concerns and had passed Mr Finch's address to Merseyside Police.
Mr Finch claimed that when he repeated the crimes to police, the force had refused to take him seriously and instead detained him for psychiatric treatment.
He claimed he had been subject to "gross indignities" during and after his detention and had failed to get redress from either Merseyside Police or Merseyside NHS Trust.
In the email, Mr Finch said it gave him "great pleasure" to reveal he had been documenting "secret, top secret and codeword" information on systems he had been working on.
"This information has been sent (freely) to a number of hostile foreign governments," the email continued.
"If the nation does not care for my security then why should I care for national security?"
'A very strange tale'
Defending Mr Finch, Stuart Trimmer QC made a short opening statement to the jury, in which he called the case "a very strange tale".
Mr Trimmer said Mr Finch had been at a "deeply troubled phase of his life" and that the events prior to this had "quite literally ruined his life".
His client had not been motivated by money or political affiliation, Mr Trimmer went on, but was an "intelligent man whose sexuality was unclear to others and in doubt to himself".
"In the result he was abused and insulted. When he sought protection he got none," he added.
Jurors will hear more details about the system during closed sessions of the court, with journalists and the public not allowed into proceedings.
The trial continues.