This paper is devoted to studying the dynamic behavior of drug transmission and the optimal strategy for controlling drug transmission. We constructed a six-dimensional drug transmission model with media coverage, family and public education, dividing the total population into six categories: high-risk susceptible individuals (S), low-risk susceptible individuals with protection awareness (P), psychological addicts (I-PC), physiological addicts (I-PS), drug addicts in community treatment (R-C), drug addicts in compulsory detoxification treatment (R-I). We first calculated the basic regeneration number and analyzed the existence and stability of the equilibrium point of the model. Then, sensitivity analysis and numerical simulations of the parameters are performed. Finally, we gained new insights that when R-0 < 1, controlling the contact between susceptible individuals and drug addicts is more effective than treatment; when R-0 > 1, anti-drug education and media coverage play a greater role, at which point prevention and treatment go hand in hand to control the drug epidemic in a more cost-effective and rapid manner.