$msg .= "Content-Type: text/plain; charset=\"iso-8859-1\"\n";

Se invii l'email dichiarandola come plain text è ovvio che il codice html non venga interpretato.