Contribution

2013-03-28
2013-06-17
  • Oliver Heil

    Oliver Heil - 2013-03-28

    Dear NOCC-Team,

    I am still using NOCC and actually like it very much. Mainly because of its slimness and its very clear code. So I did some coding for my purpose and added support for SMTP over STARTTLS.
    Also I would contribute to the project in future if this is welcome.

    I changed file classes/class_smtp.php and added the following lines:

    classes/class_smtp.php

    public function smtp_auth($smtp) {
      ...
              case 'LOGIN':
      ...
              case 'TLS':
                    fputs($smtp, "STARTTLS\r\n");
                    $this->sessionlog .= "Sent: STARTTLS";
                    $line = fgets($smtp, 1024);
                    $this->sessionlog .= "Rcvd: $line";
                    if (substr($line, 0, 1) != '2')
                            return new NoccException($html_smtp_error_unexpected . ' : ' . $line);
                    stream_socket_enable_crypto( $smtp,true,STREAM_CRYPTO_METHOD_SSLv23_CLIENT);
                    fputs($smtp, "helo " . $_SERVER['SERVER_NAME'] . "\r\n");
                    $this->sessionlog .= "Sent: helo " . $_SERVER['SERVER_NAME'];
                    $line = fgets($smtp, 1024);
                    $this->sessionlog .= "Rcvd: $line";
                    if (substr($line, 0, 1) != '2')
                            return new NoccException($html_smtp_error_unexpected . ' : ' . $line);
                    fputs($smtp, "auth login\r\n");
                    $this->sessionlog .= "Sent: auth login";
                    $line = fgets($smtp, 1024);
                    $this->sessionlog .= "Rcvd: $line";
                    if (substr($line, 0, 1) != '3')
                            return new NoccException($html_smtp_error_unexpected . ' : ' . $line);
                    fputs($smtp, base64_encode($_SESSION['nocc_login']) . "\r\n");
                    $this->sessionlog .= "Sent: encoded login";
                    $line = fgets($smtp, 1024);
                    $this->sessionlog .= "Rcvd: $line";
                    if (substr($line, 0, 1) != '3')
                            return new NoccException($html_smtp_error_unexpected . ' : ' . $line);
                    fputs($smtp, base64_encode(decpass($_SESSION['nocc_passwd'], $conf->master_key)) . "\r\n");
                    $this->sessionlog .= "Sent: encoded password";
                    $line = fgets($smtp, 1024);
                    $this->sessionlog .= "Rcvd: $line";
                    if (substr($line, 0, 1) != '2')
                            return new NoccException($html_smtp_error_unexpected . ' : ' . $line);
                    return (true);
                    break;
              case 'PLAIN':
    ...
    

    A mail server configuration with smtp over STARTTLS would look like this:

    $conf->domains[$i]->domain = 'example';
    $conf->domains[$i]->in = 'mail.example.com:993/ssl/novalidate-cert';
    $conf->domains[$i]->smtp = 'mail.example.com';
    $conf->domains[$i]->smtp_port = 587;
    $conf->domains[$i]->login_with_domain = 0;
    $conf->domains[$i]->login_with_domain_character = '@';
    $conf->domains[$i]->login_suffix = '';
    $conf->domains[$i]->login_aliases = array();
    $conf->domains[$i]->login_allowed = array('user_name' => '');
    $conf->domains[$i]->smtp_auth_method = 'TLS';
    $conf->domains[$i]->imap_namespace = "";
    $conf->domains[$i]->have_ucb_pop_server = false;
    $conf->domains[$i]->quota_enable=false;
    $conf->domains[$i]->quota_type='STORAGE';
    

    I was also looking for SMTP over SSL, but this is already possible in the existing code.
    This is an example configuration of such a smtp server:

    $conf->domains[$i]->domain = 'example';
    $conf->domains[$i]->in = 'imap.example.com:993/ssl/novalidate-cert';
    $conf->domains[$i]->smtp = 'ssl://mail.example.com';
    $conf->domains[$i]->smtp_port = 465;
    $conf->domains[$i]->login_with_domain = 0;
    $conf->domains[$i]->login_with_domain_character = '@';
    $conf->domains[$i]->login_suffix = '';
    $conf->domains[$i]->login_aliases = array();
    $conf->domains[$i]->login_allowed = array('user_name' => '');
    $conf->domains[$i]->smtp_auth_method = 'PLAIN';
    $conf->domains[$i]->imap_namespace = "";
    $conf->domains[$i]->have_ucb_pop_server = false;
    $conf->domains[$i]->quota_enable=false;
    $conf->domains[$i]->quota_type='STORAGE';
    

    I hope this helps.
    If there is the need of more contribution to this project I would be happy to get some kind of signal.

    Regards,

    Oli

     
  • Tim Gerundt

    Tim Gerundt - 2013-06-17

    Hi Oli,

    thank you for this patch! A user add it as feature-requests to the project:

    132 TLS Support for SMTP

    https://sourceforge.net/p/nocc/feature-requests/132/

    He also say, that it works! Unfortantly we have currently no active developer. :(

    Greetings,
    Tim

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks