there are many fixes to this.as it is a faulty one, open up the mac and check the motherboard for any compnents of sorts that appear non functional near to the 3.7mm jack. check continuity for any cracked components. take some acetone(nail polish remover), earbuds and blue tack. use these carefully to remove dirt.if problem persists, desolder the jackand replace it. if even that dosent work, try exposing the connector of the speakers and connect the terminals of a 9v batt to test if it works. if not, go to a reputed apple service shop.