Garrett Reid had pleaded guilty in May to trying to smuggle dozens of pills into the Montgomery County Jail.
Reid, 25, was serving time in the jail for a heroin-fueled car crash that injured a motorist.
When Reid surrendered on charges related to that crash in October, prison guards found 89 prescription pills inside his rectum.
He was sentenced Tuesday via video conference from a facility in Camp Hill by a judge at the Montgomery County courthouse in Norristown.
Reid will spend at least five more months behind bars as part of the program intended to integrate drug and alcohol addicts back into society.
A Montgomery County judge said he hoped the sentence will help Reid address a "long history of addiction," which also includes a conviction on charges related to a heroin-fueled car crash that injured a motorist.
"You are an addict," Judge Steven O'Neill told Reid. "The intention is to get this young man treatment. His addiction is deep, long-lasting and he is in need of treatment."
The two year program includes seven months of jail time - two of which Reid has already served - followed by 17 months of integration into society. That may include halfway houses, private facilities and possibly staying at private residences, Reid family attorney Paul Rosen said after the sentencing.
Reid has been in prison since November, first serving his sentence related to the DUI crash, then to be evaluated for the state rehab program.
Reid was also sentenced to three years of probation following the program. If Reid should fail to complete the program, he would return before the judge and could face two years in state prison.