Roundcube Community Forum

News and Announcements => General Discussion => Topic started by: imatthew on February 22, 2013, 05:32:10 AM

Title: Roundcube SMTP with STARTTLS authentication failed
Post by: imatthew on February 22, 2013, 05:32:10 AM
I am using roundcube opensource for my email client. The Incoming IMAP and SMTP servers working good when I use the default mechanism like "LOGIN, PLAIN" with STARTTLS. But If I use my own mechanism the incoming IMAP working good but outgoing SMTP not working. When I send email it showing "sending...". But email has not sent. what may the problem. The code snippet is given below.

I configured in main.inc.php as below.

$rcmail_config['smtp_server'] = 'tls://mail.domain.com';

$rcmail_config['smtp_port'] = 587;

$rcmail_config['smtp_user'] = '%u';

$rcmail_config['smtp_pass'] = '%p';

$rcmail_config['smtp_auth_type'] = 'my own mechanism';

Outgoing SMTP authentication code is,

function _authPlain($uid, $pwd, $authz = '')
{
if (PEAR::isError($error = $this->_put('AUTH', 'my own mechanism'))) {
    return $error;
}
/* 334: Continue authentication request */
if (PEAR::isError($error = $this->_parseResponse(334))) {
    /* 503: Error: already authenticated */
    if ($this->_code === 503) {
        return true;
    }
    return $error;
}

$auth_str = base64_encode($authz . chr(0) . $uid . chr(0) . $pwd);

if (PEAR::isError($error = $this->_put($auth_str))) {
    return $error;
}

/* 235: Authentication successful */
if (PEAR::isError($error = $this->_parseResponse(235))) {
    return $error;
}
 return true;
}