mail function in place