Refactor promise message sending function.