#####################
#  __   _  _        #
# /__| / \|_) /\ |  #
# \_||_\_/|_)/--\|_ #
#                   #
#####################

# Attempt to keep the time-stamp based
# sorting intact
CopyArrivalDate yes
# Automatically create missing mailboxes,
# both locally and on the server
Create Near
# The per-Channel, per-direction instantaneous
# memory usage above which mbsync will refrain
# from using more memory.
BufferLimit 100M


##########################
#      _ _ _       _____ #
#  /\ / / / \| ||\ ||(_  #
# /--\\_\_\_/|_|| \||__) #
#                        #
##########################

{{ range $value := .mbsync }}

# {{ $value.name }}
#-------------------------

IMAPAccount {{ $value.name }}
# Address to connect to
Host {{ $value.server }}
User {{ $value.username }}
PassCmd "pass {{ $value.server }}/{{ $value.username }}"
# Use SSL
# SSLType IMAPS
SSLType None
# The following line should work.
# If get certificate errors, uncomment the two
# following lines and read the "Troubleshooting" section.
CertificateFile /etc/ssl/certs/ca-certificates.crt


IMAPStore {{ $value.name }}-remote
Account {{ $value.name }}


MaildirStore {{ $value.name }}-local
SubFolders Verbatim
# The trailing "/" is important
Path ~/Mail/{{ $value.name }}/
Inbox ~/Mail/{{ $value.name }}/inbox


Channel {{ $value.name }}-inbox
Far :{{ $value.name }}-remote:
Near :{{ $value.name }}-local:inbox
Sync PullNew PullDelete Push
SyncState *
# Remove Both
Expunge Both


Channel {{ $value.name }}-sent
Far :{{ $value.name }}-remote:"Sent Items"
Near :{{ $value.name }}-local:sent
Sync PullNew PullDelete Push
SyncState *
Expunge Both


Channel {{ $value.name }}-trash
Far :{{ $value.name }}-remote:"Deleted Items"
Near :{{ $value.name }}-local:trash
Sync PullNew PullDelete Push
SyncState *
Expunge Both


Channel {{ $value.name }}-drafts
Far :{{ $value.name }}-remote:"Drafts"
Near :{{ $value.name }}-local:drafts
Sync PullNew PullDelete Push
SyncState *
Expunge Both


Channel {{ $value.name }}-junk
Far :{{ $value.name }}-remote:"Junk Email"
Near :{{ $value.name }}-local:junk
Sync PullNew PullDelete Push
SyncState *
Expunge Both


Channel {{ $value.name }}-archive
Far :{{ $value.name }}-remote:"Archive"
Near :{{ $value.name }}-local:archive
Pattern *
Create Near
MaxMessages 1500
Sync New Delete Push
SyncState *
Expunge Both


Group {{ $value.name }}
Channel {{ $value.name }}-inbox
Channel {{ $value.name }}-sent
Channel {{ $value.name }}-trash
Channel {{ $value.name }}-drafts
Channel {{ $value.name }}-junk
Channel {{ $value.name }}-archive

{{ end }}