Kevin Abel is providing some of the PHP extensions removed from Homebrew/core. You can install the IMAP extension with:
brew tap kabel/php-ext
brew install php-imap
To install a specific version, such as 7.2 use:
brew install php-ext/[email protected]