what you will need is a long handled sledge hammer, some hardwood 3 foot stakes, a chain, and a come along, or fence stretcher.
You will need to address each post individually. On the side that its leaning onto, drive a stake into the ground at an angle away from the fence, drive the stake a good foot or more into the ground. Attach your come along to the stake, then stretch it out and then attach the other end to the fence post top. With a friend holding a level on the post, have another begin cranking down on the come along. Stop when the post is level. Then on the other side of the post, tamp down the soil and fill in the void. Or even pour cement into this void.
Leave the apparatus on the post for a good day or more.
Then move to the other post and repeat this operation.
Now, if the lean is toward the neighbor, then do this same operation and jump to the other side and wedge a 2x4 against the post and nail a cleat to that post for the 2x4 to anchor to. Then drive a stake into the ground behind the 2x4 to stop it from slipping on the ground. Once leve is achieved, remove the stuff from the neighbor side and this will work too.