moved sendmail functions