{{#if currentUser.admin}}
  <div class="control-group">
    <label class="control-label">{{i18n "groups.manage.email.credentials.title"}}</label>
  </div>

  {{#if model.imap_last_error}}
    <div class="alert alert-error">{{model.imap_last_error}}</div>
  {{else}}
    <div class="alert alert-info">
      {{i18n "groups.manage.email.status" old_emails=oldEmails total_emails=totalEmails}}
    </div>
  {{/if}}

  <div class="control-group">
    <label for="smtp_server">{{i18n "groups.manage.email.credentials.smtp_server"}}</label>
    {{input type="text" name="smtp_server" value=model.smtp_server}}
  </div>

  <div class="control-group">
    <label for="smtp_port">{{i18n "groups.manage.email.credentials.smtp_port"}}</label>
    {{input type="text" name="smtp_port" value=model.smtp_port}}
  </div>

  <div class="control-group">
    <label class="control-group-inline" for="smtp_ssl">
      {{input type="checkbox" name="smtp_ssl" id="smtp_ssl" checked=model.smtp_ssl}}
      {{i18n "groups.manage.email.credentials.smtp_ssl"}}
    </label>
  </div>

  <div class="control-group">
    <label for="imap_server">{{i18n "groups.manage.email.credentials.imap_server"}}</label>
    {{input type="text" name="imap_server" value=model.imap_server}}
  </div>

  <div class="control-group">
    <label for="imap_port">{{i18n "groups.manage.email.credentials.imap_port"}}</label>
    {{input type="text" name="imap_port" value=model.imap_port}}
  </div>

  <div class="control-group">
    <label class="control-group-inline" for="imap_ssl">
      {{input type="checkbox" name="imap_ssl" checked=model.imap_ssl id="imap_ssl"}}
      {{i18n "groups.manage.email.credentials.imap_ssl"}}
    </label>
  </div>

  <div class="control-group">
    <label for="username">{{i18n "groups.manage.email.credentials.username"}}</label>
    {{input type="text" name="username" value=model.email_username}}
  </div>

  <div class="control-group">
    <label for="password">{{i18n "groups.manage.email.credentials.password"}}</label>
    {{input type="password" name="password" value=model.email_password}}
  </div>

  <div class="control-group">
    {{#if mailboxes}}
      <label for="imap_mailbox_name">{{i18n "groups.manage.email.mailboxes.synchronized"}}</label>
      {{combo-box name="imap_mailbox_name"
                  value=model.imap_mailbox_name
                  valueProperty="value"
                  content=mailboxes
                  none="groups.manage.email.mailboxes.disabled"
                  onChange=(action (mut model.imap_mailbox_name))}}
    {{else}}
      {{i18n "groups.manage.email.mailboxes.none_found"}}
    {{/if}}
  </div>

  <div class="control-group">
    <label class="control-label">{{i18n "groups.manage.email.settings.title"}}</label>
  </div>
  <div class="control-group">
    <label class="control-group-inline" for="allow_unknown_sender_topic_replies">
      {{input type="checkbox" name="allow_unknown_sender_topic_replies" id="allow_unknown_sender_topic_replies" checked=model.allow_unknown_sender_topic_replies}}
      <span>{{i18n "groups.manage.email.settings.allow_unknown_sender_topic_replies"}}</span>
    </label>
    <p>{{i18n "groups.manage.email.settings.allow_unknown_sender_topic_replies_hint"}}</p>
  </div>
{{/if}}
