% layout 'AdminLTE', title => "Sme server 2 - emailreceive";

% content_for 'module' => begin

% use constant FALSE => 0;
% use constant TRUE  => 1;

<div class="card-body">

    % if (config->{debug} == 1) {
    <p>
    %= dumper $c->current_route
    %= dumper $mai_datas
    %= dumper $c->param('SMTPAuth')
    </p>
    % }

    % if ( stash 'error' ) {
        <br>
        <div class="">
        %= $c->render_to_string(inline => stash 'error') 
        </div>
    %}
    
    <h1><%= $title%></h1>

    %= form_for '/emailsettingd' => (method => 'POST') => begin

    %=l 'mai_DESC_MODE'

    <p>
    <span class="">
    %=l 'mai_LABEL_MODE'
    </span>
    <span class="">
    % param 'FetchmailMethod' => $mai_datas->{fetchmailmethod} unless param 'FetchmailMethod';
<!--
    <pre>
        %= dumper $mai_datas->{fetchmailmethod}
        %= dumper $c->get_retrieval_opt()
        %= param 'FetchmailMethod'
    </pre>
-->
    %= select_field 'FetchmailMethod' => $c->get_retrieval_opt(), class => ""
    </span>
    </p>

    %#=l 'mai_DESC_SMTP_AUTH_CONTROL'
    <br />
    %= l "SMTP port (25) main purpose is to receive emails from another server, STARTTLS is always offered, but auth if offered is only if STARTTLS is also used by client."
    <br />
    %= l "SMTPS port (465) will require implicit SSL/TLS then authenticate to send."
    <br />
    %= l "SMTP Submission port (587) will require STARTTLS, then authenticate to send."
    <br />

    % my $smtp_mesg=l('SMTP port %u allow client to authenticate:');
    <p>
    <span class="">
        %= sprintf($smtp_mesg,$c->get_db_prop('qpsmtpd','TCPPort',25)); 
    </span>
    <span class="">
        % param 'SMTPAuth' => $c->get_current_smtp_auth( FALSE ) unless param 'SMTPAuth';
<!--
    <pre>
        %= dumper $c->get_smtp_auth_opt()
        %= dumper $c->get_current_smtp_auth(FALSE)
        %= dumper $c->get_db_prop("qpsmtpd","Authentication")
        %= param 'SMTPAuth'
    </pre>
-->
        %= select_field 'SMTPAuth' => $c->get_smtp_auth_opt(), class => ""
    </span>
    </p>

    % my $smtp_mesg=l('SMTPS SSL/TLS auth: port %u status:');
    <p>
    <span class="">
        %= sprintf($smtp_mesg,$c->get_db_prop('sqpsmtpd','TCPPort',465)); 
    </span>
    <span class="">
        % param 'sSMTPAuth' => $c->get_current_smtp_ssl_auth(FALSE,'s', TRUE) unless param 'sSMTPAuth';    
        %= select_field 'sSMTPAuth' => $c->get_smtp_ssl_auth_opt(), class => ""
    </span>
    </p>

    %my $smtp_mesg=l('Submission port %u status:');
    <p>
    <span class="">
        %= sprintf($smtp_mesg,$c->get_db_prop('uqpsmtpd','TCPPort',587)); 
    </span>
    <span class="">
        % param 'uSMTPAuth' => $c->get_current_smtp_ssl_auth(FALSE,'u', TRUE) unless param 'uSMTPAuth';
    <!--
    <pre>
        %= dumper $c->get_smtp_ssl_auth_opt()
        %= dumper $c->get_current_smtp_ssl_auth(FALSE,'s', TRUE)
        %= dumper $c->get_current_smtp_ssl_auth(FALSE,'u', TRUE)
        %= dumper $c->get_db_prop("uqpsmtpd","access")
        %= param 'uSMTPAuth'
    </pre>
    -->
    %= select_field 'uSMTPAuth' => $c->get_smtp_ssl_auth_opt(), class => ""
    </span>
    </p>

    <!--<hr class="" />-->
    <h2>
    %=l 'mai_TITLE_SECONDARY'
    </h2>

    %=l 'mai_DESC_SECONDARY'

    <p>
    <span class="">
    %=l 'mai_LABEL_SECONDARY'
    </span>
    <span class="">
    % param 'SecondaryMailServer' => $mai_datas->{secondarymailserver} unless param 'SecondaryMailServer';
    %= text_field 'SecondaryMailServer', class => ""
    </span>
    </p>

    %=l 'mai_DESC_FETCH_PERIOD'

    <p>
    <span class="">
    %=l 'mai_LABEL_FETCH_PERIOD'
    </span>
    <span class="">
    % param 'FreqOffice' => $mai_datas->{freqoffice} unless param 'FreqOffice';
    %= select_field 'FreqOffice' => $c->fetchmail_freq(), class => ""
    </span>
    </p>

    <p>
    <span class="">
    %=l 'mai_LABEL_FETCH_PERIOD_NIGHTS'
    </span>
    <span class="">
    % param 'FreqOutside' => $mai_datas->{freqoutside} unless param 'FreqOutside';
    %= select_field 'FreqOutside' => $c->fetchmail_freq(), class => ""
    </span>
    </p>

    <p>
    <span class="">
    %=l 'mai_LABEL_FETCH_PERIOD_WEEKENDS'
    </span>
    <span class="">
    % param 'FreqWeekend' => $mai_datas->{freqweekend} unless param 'FreqWeekend';
    %= select_field 'FreqWeekend' => $c->fetchmail_freq(), class => ""
    </span>
    </p>

    <p>
    <span class="">
    %=l 'mai_LABEL_POP_ACCOUNT'
    </span>
    <span class="">
    % param 'SecondaryMailAccount' => $mai_datas->{secondarymailaccount} unless param 'SecondaryMailAccount';
    %= text_field 'SecondaryMailAccount', class => ""
    </span>
    </p>

    <p>
    <span class="">
    %=l 'mai_LABEL_POP_PASS'
    </span>
    <span class="">
    % param 'SecondaryMailPassword' => $mai_datas->{secondarymailpassword} unless param 'SecondaryMailPassword';
    %= password_field 'SecondaryMailPassword', class => ""
    </span>
    </p>

    <p>
    <span class="">
    %=l 'mai_LABEL_SORT_METHOD'
    </span>
    <span class="">
    % param 'SpecifyHeader' => $mai_datas->{specifyheader} unless param 'SpecifyHeader';
    %= select_field 'SpecifyHeader' => [[(l 'mai_DEFAULT') => 'off'], [(l 'mai_SPECIFY_BELOW') => 'on']], class => ""
    </span>
    </p>

    <p>
    <span class="">
    %=l 'mai_LABEL_SORT_HEADER'
    </span>
    <span class="">
    % param 'SecondaryMailEnvelope' => $mai_datas->{secondarymailenvelope} unless param 'SecondaryMailEnvelope';
    %= text_field 'SecondaryMailEnvelope', class => ""
    </span>
    </p>

    %   my $btn = l('SAVE');
    %= submit_button "$btn", class => ""

    %= hidden_field 'trt' => 'REC'
    % end    

</div>
%end