I got it working with the following settings:
$config['imap_host'] = 'ssl://127.0.0.1:993';
// Required if you're running PHP 5.6 or later
$config['imap_conn_options'] = array (
'ssl' => array (
'verify_peer' => true,
'verify_peer_name' => false,
'verify_depth' => 3,
'catfile' => '/etc/letsencrypt/live/mail.myserver.com/cert.pem',
),
);
I'm not sure if this is the correct way to do it, but it's working...