working mail sending functionality