When, by an agreement with the assured or by the terms of a fire insurance policy taken out by a mortgagor, the whole or any part of the loss thereon is payable to the mortgagee or mortgagees of the property for their benefit, the company shall, upon satisfactory proof of the rights and title of the parties, in accordance with such terms and agreement, pay all mortgagees protected by such policy in the order of their priority of claim, as their claims shall appear, not beyond the amount of which the company is liable. Such payments shall be, to the extent thereof, payments and satisfaction of the liabilities of the company under such policy.