Previous to a clearance being granted to any vessel, outward bound, the legal fees which shall have accrued on such vessel shall be paid at the offices where such fees are respectively payable; and receipts for the same shall be produced to the collector or other officer whose duty it may be to grant clearances, before a clearance is granted.