The man in question, a director at logistical company Gartner KG, was charged with unlawful disclosure of personal information, Spanish daily 20minutos reported on Tuesday.
He was however acquitted of slander despite having referred to the two employees he spied on as "sick".
According to the judge, it couldn't be completely proven that he uttered the term with the intent of "insulting or undermining" the men.
It was the fact that he intentionally accessed their email addresses without permission and passed on alleged proof of their homosexuality to his superiors that has landed the accused a jail sentence.
In correspondence with Gartner KG's head office in Austria, the man said the emails included "incredibly filthy content" and showed concern over the fact that both men "unfortunately get on very well".
The judge dismissed the accused's claims that he accessed his employees’ emails for work reasons, letting him know that it made no sense to access them if they were indeed so "filthy", and therefore not work related.
"Sexual orientation cannot be considered a hindrance in the workplace, nor should it be disclosed up the hierarchical ladder," the judge told the Barcelona court.
Although the accused wasn't sentenced for slander, this is the first court case dealing with homophobia in the workplace in Spain.