If you get the following error:
Error connecting to IMAP server: localhost.
0 : php_network_getaddresses: getaddrinfo failed: Name or service not known It usually means that the following code is missing from your /etc/hosts file.
127.0.0.1 localhost
Edit the /etc/hosts file and ensure it's present.