"This foam is caused by the formation of a crude soap on the bark from fatty acids in pine sap/resin. Over a drought a mix of sap salts and acids accumulates and coats the bark surface to form the basics of a rough detergent. When it rains, these ingredients mix with the water and start sudsing up. The froth (foam) is from the agitation of the mixture as it runs down the rough bark during its flow toward the ground.
So it’s perfectly normal when your pine suds up in the rain (although if it does so excessively, it may indicate that there is some insect or other damage that is causing it to “bleed” more sap)."