mail to function with field validation