implements emailing to user

implements emailing to user
fixes some bugs