Steven McIvor, 32, was one of two thieves who targeted the Letterbox Bistro in Balerno Main Street and stole Â£2,000 and 5,300 Euros on 26 February 2016.
McIvor, from Edinburgh, was found guilty after trial.
His co-accused Eddie Moffat, 27, was acquitted of the robbery charge on a not proven verdict.
The owner of the post office/bistro business Steven Carlyle, 55, said he was talking to his son when he became aware of two men entering the premises.
He told the court: "Then the language got worse and they demanded money. They were demanding all the money from the till and the Euros."
"The thieves had scarves over their mouths and each was armed with a knife.
Mr Carlyle said he pressed an alarm that was supposedly inaudible but turned out to be audible. He said: "That's when they started getting very agitated."
One of the intruders became very aggressive and a knife was thrust through a gap in a Perspex screen.
Mr Carlyle said: "They were swearing all the time, telling us to 'hurry up, get the money, get the cash'."
At the High Court in Glasgow Lord Kinclaven jailed McIvor and told him: "You assaulted Mr Carlyle, who was behind the counter. There was no physical injury, but it must have been a frightening and traumatic incident for those in the post office at the time."
The court was told McIvor, who has 17 pages of previous conviction, had a drug problem.
None of his previous convictions were for violence.
Det Insp Graham Grant, of Police Scotland, said: "Steven McIvor showed no regard for the welfare of the member of staff during this robbery.
"Thankfully a swift policing response involving uniformed officers, CID, road policing and specialist Police Scotland resources ensured that he was traced and detained quickly.
"Crimes of this nature will not be tolerated when they occur and we will use all resources at our disposal to bring those responsible to justice."

It is hoped the theatre, founded in 1875, will be used for theatrical performances, cinema screenings, comedy and live music.
The BBC studios, at the eastern end of the Palace, will also be repaired and refurbished.
If successful in raising funds it is hoped the theatre will reopen in 2018.
The theatre and studios form part of a larger east wing restoration project to transform Alexandra Palace into a new cultural destination.
As part of the renovations, the glazed east court will become a space for the public and for exhibitions.
Heritage Lottery Fund (HLF) is contributing £18.8m towards the project, while Haringey Council is contributing £6.8m.
The entire east wing will be refurbished at a cost of £26.6m.
Alexandra Park and Palace Charitable Trust have committed to raising the final £1m by summer 2017.
The theatre, which has languished unused for decades, still has much of its original decor and stage machinery in place.
It was created to showcase opera, musicals, plays and all kinds of entertainment, even hosting early cinema screenings.
A man who raided a post office on the outskirts of Edinburgh has been jailed for seven years.
[NEXT_CONCEPT]
Alexandra Palace has started a £1m fundraising campaign to bring its Victorian theatre back to life after lying unused for 80 years.