Fixed sendmail function