update code then compatible with php5.2

make code compatible with php5.2 and add sendMail function