updated mail sending logic, using php mail instead of library