aboutsummaryrefslogtreecommitdiffstats
path: root/config
diff options
context:
space:
mode:
Diffstat (limited to 'config')
-rw-r--r--config/accounts.go22
-rw-r--r--config/templates.go1
2 files changed, 22 insertions, 1 deletions
diff --git a/config/accounts.go b/config/accounts.go
index 4d1d60bf..77afa0f9 100644
--- a/config/accounts.go
+++ b/config/accounts.go
@@ -69,7 +69,8 @@ func (c *RemoteConfig) ConnectionString() (string, error) {
}
type AccountConfig struct {
- Name string
+ Name string
+ Backend string
// backend specific
Params map[string]string
@@ -247,6 +248,8 @@ func ParseAccountConfig(name string, section *ini.Section) (*AccountConfig, erro
if account.Source == "" {
return nil, fmt.Errorf("missing 'source' parameter")
}
+
+ account.Backend = parseBackend(account.Source)
if account.From == nil {
return nil, fmt.Errorf("missing 'from' parameter")
}
@@ -269,6 +272,23 @@ func ParseAccountConfig(name string, section *ini.Section) (*AccountConfig, erro
return &account, nil
}
+func parseBackend(source string) string {
+ u, err := url.Parse(source)
+ if err != nil {
+ return ""
+ }
+ if strings.HasPrefix(u.Scheme, "imap") {
+ return "imap"
+ }
+ if strings.HasPrefix(u.Scheme, "maildir") {
+ return "maildir"
+ }
+ if strings.HasPrefix(u.Scheme, "jmap") {
+ return "jmap"
+ }
+ return u.Scheme
+}
+
func (a *AccountConfig) ParseSource(sec *ini.Section, key *ini.Key) (string, error) {
var remote RemoteConfig
remote.Value = key.String()
diff --git a/config/templates.go b/config/templates.go
index edcd3abb..5a38cd61 100644
--- a/config/templates.go
+++ b/config/templates.go
@@ -65,6 +65,7 @@ var (
)
func (d *dummyData) Account() string { return "work" }
+func (d *dummyData) AccountBackend() string { return "maildir" }
func (d *dummyData) Signature() string { return "" }
func (d *dummyData) Folder() string { return "INBOX" }
func (d *dummyData) To() []*mail.Address { return []*mail.Address{&addr1} }