lib send-mail function