adaptation of RMail library