Hamels pitches Phillies past Red Sox 6-4