sounds like inflammatory bowl disease to me - what are ingredients of food? Did you switch over slowly? Make sure no chicken or white potato in diet and google inflammatory foods and stay clear of them and no treats with dogs with digestive issues as they need to be on a basic diet. If you switched too fast that can be an issue. White foam means all bile is vomitted out of stomach and stomach is empty - if food is not going down and vomitting back up undigested then ibd in small intestines and may be why he was turned in
this runs in this breed. My dog has it. A limited ingredient diet may be best
another thing is since you just got him he could be stressed and stress colitis is also a possibility so try this before doing food switch - soak the kibble so it is soft and easier to digest and see how he does - it may take a month of doing this to calm him down, get him use to new environment and settle his intestines. If soaking food does not work then a diet change may be in order - kibble is much harder to digest than wet