Feedback and metal enrichment in cosmological SPH simulations – II. A multiphase model with supernova energy feedback