If a wooden fence has an Achilles heel, it's the point where each fence post exits the ground. This area is especially vulnerable to rot due to ground contact or water pooling around the top of a concrete base. You can repair a 4x4 fence post that has rotted and/or broken near the ground by bolstering it with a shorter support post set in the ground just behind the original. If the post is damaged farther up along its length, you can sandwich it with a 2x4 on each side of the damaged area, bolting through all three pieces with galvanised carriage bolts.
Support the fence panels on both sides of the posts with lumber or masonry blocking set under the bottom horizontal rails. Cut off the bottom of the post just above the damaged or rotted area using a reciprocating saw or a handsaw.
Break up any concrete collar or base surrounding the post using a cold chisel and a maul. Remove the buried portion of the post.
Dig out the original post hole, as needed, to accommodate a new support post behind the original post. If you will backfill the hole with concrete, make the hole about 12 inches in diameter. If you will backfill with soil, leave as much of the existing ground intact as possible. (Undisturbed soil is already compacted and will be more stable than tamped backfill soil.)
Cut a length of 4x4 post (use pressure-treated lumber rated for ground contact) to extend about 30 inches into the ground and about 24 inches above the bottom cut on the original post. Add a few inches of drainage gravel to the bottom of the hole and tamp it with a scrap 2x4 or 4x4.
Set the support post into the hole and drill pilot holes for three or more 1/2-inch-diameter galvanised carriage bolts running through both posts. Drill a counterbore on the nut side of each bolt hole so the washers and nuts are recessed into the wood. Anchor the posts together with the bolts and washers and nuts, tightening the nuts with a socket wrench.
Backfill the hole with soil or concrete, as desired. If using soil, add the dirt a few inches at a time, tamping each layer thoroughly before adding the next. Mound the soil or concrete slightly above the ground to help shed water away from the support post. Remove the blocking under the fence panels after the concrete has cured.