Go to an auto body paint supply place. They sell glue specifically made just for what you are talking about. It's called like panel bonding adhesive or seam sealer. Maybe a body guy here could give you the name of it. But a paint supply place will be able to point you to the right product.
Not even close to the expandable foam you buy from Home Depot..