Primary and secondary alcohols can be converted to haloalkanes with reagents such as: phosphorus tribromide, phosphorus trichloride, thionyl chloride, and phosphorus pentachloride.
The mechanism of these reactions is of the SN2 type and only primary and secondary alcohols react. Let's look at the mechanism of the first reaction.
Stage 1 . Alcohol attack on phosphorus tribromide
Stage 2. Bimolecular nucleophilic substitution, with bromide acting as nucleophile
All the bromines of PBr3 are reactive and the mechanism is repeated two more times.