fix sendmail.py bug and add dir support