David Blair Wilson was told by Lord Jones at the High Court in Edinburgh he had abused his position as a lawyer.
An earlier trial saw dramatic CCTV footage of plain clothes police blocking any attempt by Blair Wilson to drive away in his silver hatchback, then leading him away in handcuffs.
A search of the Vauxhall uncovered the phones, diazepam tablets which could have been worth £2800 at inflated prison prices, cannabis resin with a prison value of £4000 and other contraband items.
Passing sentence, Judge Lord Jones said: “The illegal drugs were intended for onward supply within the prison. The misuse of drugs in prison is a well-recognised problem to which you were intent on contributing.
“You knew that as a solicitor visiting a client in prison you were in a privileged position. You cynically abused the privilege you had been given and abused the trust placed in you.”
The smuggling attempt was a well-planned operation, the judge added.
Blair Wilson, 55, of 46 Edgar Street, Dumfermline, insisted he did not know the suspect packages were there and blamed another man for any wrong-doing.
Today, defence advocate Susan Duff, asking for leniency, paid tribute to Blair Wilson as a solicitor.
“He has had a long and successful career in the law, a career built on hard work and a deeply committed attitude of care for his clients,” she said.
He always tried to ensure that those caught up in the criminal justice system felt they had been treated fairly, she added.
“Blair Wilson was a man for whom nothing was too much trouble.”
Now, she said, he knew he would never work again in that profession.
“He accepts your lordship must impose a custodial sentence and it is difficult to look to the end of that sentence.
“His life, as he knew it, came to an end on October 6 2011.”
The trial heard of a bizarre triangle involving the solicitor, a heroin-addicted drug dealer he befriended more than a decade ago when he was a homeless teenager and a samurai-sword wielding thug.
It also seemed that detectives had been waiting to ambush Blair Wilson - but nothing was said during the trial about what, or who, had prompted their suspicions.
On the day he was caught the solicitor had arranged to visit - in his professional capacity - Lee Brown, 35, who told the trial he was serving a total of eighteen and a half years, a sentence for attempted murder dating back to 2004 with “a few bits and bobs” added since then.
CCTV footage showed Blair Wilson arriving at the Saughton jail carrying a bulging folder.
Prison officer Graham Robertson, 25, described how he checked Blair Wilson’s ID and his colleague told the solicitor his folder had to be scanned.
“He became quite anxious looking, began to sort of fidget. His body language changed slightly,” said the prison officer.
Blair Wilson returned, briefly, to his Vauxhall Signum then came back into the prison vestibule. This time his file was noticeably thinner.
In the witness box, Blair Wilson said the suspect packages - the contents masked by white paper inside heat-sealed laminated envelopes - were nothing to do with him.
He said Steven Douglas - the youth he had befriended who regarded him as a mentor and surrogate dad - must have put them under the driver’s seat when he borrowed the car the previous evening.
There were 19 fingerprints on the packages which matched those of Mr Douglas. Not a single one matched Blair Wilson’s prints.
Mr Douglas should have appeared as a witness - but when asked where he was, Blair Wilson replied: “I wish I knew.”
A jury’s majority verdict convicted Blair Wilson of attempting to smuggle three mobile phones, three SIM cards along with two chargers and two earphones into the jail.
He was also found guilty, by majority, of being concerned in the supply of cannabis resin, diazepam and body-building drugs - in particular to Lee Brown.
During the trial, charges of breaching the Prisons (Scotland) Act by introducing drugs into the jail were dropped.
Today, Lord Jones said he was taking into account Blair Wilson was a first offender who also suffered from serious health problems.
“Whilst I take these matters into consideration, it has to be recognised that you chose to commit these offences and did this with your eyes open, knowing what the risks were and the consequences if you were caught.”