[general]
accounts = {{ mailbox.email }}
# pythonfile = ~/.offlineimap.py

[Account {{ mailbox.email }}]
localrepository = {{ mailbox.email }}_Local
remoterepository = {{ mailbox.email }}_Remote

maxage = {{ mailbox.load_from_date }}

[Repository {{ mailbox.email }}_Local]
type = Maildir
localfolders = {{ mailbox.maildir_path }}

[Repository {{ mailbox.email }}_Remote]
type = IMAP

# Конвертируем в utf8
utf8foldernames = True

# Односторонняя синхронизация
readonly = True

# Обрезаем префиксы INBOX. у папок
# Не делаем
# nametrans = lambda foldername: re.sub('^INBOX\.', '', foldername)

# Фильтруем ненужные папки
# Exchange and Office365
folderfilter = lambda folder: folder not in [
 'Calendar',
 'Calendar/Birthdays',
 'Calendar/Sub Folder 1',
 'Calendar/Sub Folder 2',
 'Calendar/United States holidays',
 'Contacts',
 'Contacts/Sub Folder 1',
 'Contacts/Sub Folder 2',
 'Contacts/Skype for Business Contacts',
 'Deleted Items',
 'Drafts',
 'Journal',
 'Junk Email',
 'Notes',
 'Outbox',
 'Sync Issues',
 'Sync Issues/Conflicts',
 'Sync Issues/Local Failures',
 'Sync Issues/Server Failures',
 'Tasks',
 'Tasks/Sub Folder 1',
 'Tasks/Sub Folder 2',
 # Спам и корзина
 'Trash',
 'Spam',
 'INBOX.Trash',
 'INBOX.Spam',
 # Отключенные папки
{% for disabled_folder_name in disabled_folder_names %}
 '{{ disabled_folder_name }}',
{% endfor %}
 ]


remotehost = {{ mailbox.imap_server or 'imap.' + mailbox.email.split('@')[-1] }}
{% if mailbox.imap_port %}
remoteport = {{ mailbox.imap_port }}
{% endif %}
{% if mailbox.imap_crypt == 'ssl' %}
ssl = yes
{% if not mailbox.imap_port %}remoteport = 993{% endif %}
{% else %}
ssl = no
{% if not mailbox.imap_port %}remoteport = 143{% endif %}
{% endif %}

sslcacertfile = /etc/ssl/certs/ca-certificates.crt
{% if mailbox.imap_crypt != 'starttls' %}
starttls = no
{% endif %}

remoteuser = {{ mailbox.login or mailbox.email }}

{% if not mailbox.password.is_null %}
# password type auth
remotepass = {{ mailbox.password.decrypt().replace('%', '%%') }}
{% else %}
# no auth provided
{% endif %}


