A hacker has been jailed for two years in Spain for revealing hundreds of private emails written by a former colleague. The emails, which were taken from the former manager's work computer, divulged details of his sex life.

The hacker sent them to the manager's ex-wife, to a woman with whom he was having a relationship, and to the mayor of a council where he was working.

The emails were also copied on to other people who knew the victim.

A judge in Barcelona yesterday jailed the hacker, who was not named, for two years for an offence of "revealing secrets". He was also ordered to pay a fine of €3,240 (£2,566) as well as €4,000 in compensation to the victim.

The judge ruled Spanish law allowed the courts to pursue anyone who "gets access to information of a personal or family nature held on information systems or computers which are public or private".

He said Spain's supreme court ruled the right to privacy "means the existence of a reserved area away from others which is necessary to maintain a minimum quality of human life".

In this case, only 2% of the emails contained information "of a highly personal nature". The judge said the way in which the victim's right to privacy had been violated was the most important factor, rather than the content of the emails.

The manager left the Barcelona company in 2006 and believed he had erased all his personal emails.

His former colleague's motive for hacking into his computer was not made clear in court. Nor did the court establish how the hacker managed to access the emails after the former manager believed they had been erased.