Accessing Yandex from RoundCube over SSL

I have installed RroundCube (Using PHP) on a sub-domain (http://email.risc.work) and using Yandex to host mailing services for my domain (http://risc.work).
IMAP is enabled at Yandex and I can access it from Gmail as well using required credential(s)

The config.inc.php file at email.risc.work/htdocs/config/ as configured accordingly as well, as described below

$config['default_host'] = 'ssl://imap.yandex.com';
$config['default_port'] = 993;

$config['smtp_server'] = 'ssl://smtp.yandex.com';
$config['smtp_port'] = 465;
$config['smtp_user'] = '%u';
$config['smtp_pass'] = '%p';

$config['ip_check'] = true;

$config['des_key'] = **<REDUCTED FOR SECURITY>**;

$config['username_domain_forced'] = true;
$config['username_domain'] = 'risc.work';

However, each time I try to login from RoundCube at http://email.risc.work, I am getting error stating Connection to IMAP Server Failed. I am not getting any such issues as being able to successfully send and receive mail using Gmail with exact same credential.

Tagging @Admin and @Ergastolator1 as you helped me to solve similar issues earlier

Did you try to enable debug mode to see if you could get more information. I found this article which lists a few options you could try.

https://docs.iredmail.org/debug.roundcubemail.html

This is what I am getting as error code @Admin

IMAP Error in /home/vol1_1/epizy.com/epiz_24215057/email.risc.work/htdocs/program/lib/Roundcube/rcube_imap.php (196): Login failed for sandeepan@risc.work from 162.158.154.154(X-Real-IP: 162.158.154.154,X-Forwarded-For: 162.158.154.154). Could not connect to ssl://imap.yandex.com:993: Unknown reason

Fixed it

// ----------------------------------
// IMAP
// ----------------------------------
// The IMAP host chosen to perform the log-in.
// Leave blank to show a textbox at login, give a list of hosts
// to display a pulldown menu or set one host as string.
// To use SSL/TLS connection, enter hostname with prefix ssl:// or tls://
// Supported replacement variables:
// %n - hostname ($_SERVER['SERVER_NAME'])
// %t - hostname without the first part
// %d - domain (http hostname $_SERVER['HTTP_HOST'] without the first part)
// %s - domain name after the '@' from e-mail address provided at login screen
// For example %n = mail.domain.tld, %t = domain.tld
// WARNING: After hostname change update of mail_host column in users table is
//          required to match old user data records with the new host.

$config['default_host'] = 'ssl://imap.yandex.com';

$config['imap_conn_options'] = array(
'ssl' => array(
'verify_peer' => false,
'verfify_peer_name' => false,
),
);

// TCP port used for IMAP connections
$config['default_port'] = 993;

// ----------------------------------
// SMTP
// ----------------------------------
// SMTP server host (for sending mails).
// Enter hostname with prefix tls:// to use STARTTLS, or use
// prefix ssl:// to use the deprecated SSL over SMTP (aka SMTPS)
// Supported replacement variables:
// %h - user's IMAP hostname
// %n - hostname ($_SERVER['SERVER_NAME'])
// %t - hostname without the first part
// %d - domain (http hostname $_SERVER['HTTP_HOST'] without the first part)
// %z - IMAP domain (IMAP hostname without the first part)
// For example %n = mail.domain.tld, %t = domain.tld

$config['smtp_server'] = 'ssl://smtp.yandex.com';

$config['smtp_conn_options'] = array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
),
);

// SMTP port (default is 25; use 587 for STARTTLS or 465 for the
// deprecated SSL over SMTP (aka SMTPS))
$config['smtp_port'] = 465;

// SMTP username (if required) if you use %u as the username Roundcube
// will use the current username for login
$config['smtp_user'] = '%u';

// SMTP password (if required) if you use %p as the password Roundcube
// will use the current user's password for login
$config['smtp_pass'] = '%p';