added send mail function. still needs some cleaning (temporary stuff...)