diff options
author | Koni Marti <koni.marti@gmail.com> | 2022-07-11 20:11:19 +0200 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2022-07-14 23:14:50 +0200 |
commit | c24a57687697411cde3bdcf39700385e7a689798 (patch) | |
tree | f7f599ac90555db5dae8f5eeb06a675893ccf500 /widgets/aerc.go | |
parent | a1a276e002b937e38585c1fe547bd0c00bc525c1 (diff) | |
download | aerc-c24a57687697411cde3bdcf39700385e7a689798.tar.gz |
aerc: use aerc as an mbox viewer
Use Aerc as an mbox viewer. Open an mbox file from the command line in a
new tab with the mbox backend. Provide a convenient and quick way to
display emails from an mbox.
Usage: aerc mbox://<path>
where the path can either be a directory or an mbox file. If it is a
directory, every file with an .mbox suffix will be loaded as a folder.
The account config will be copied from the selected account. This allows
the answer emails in the mbox account.
Signed-off-by: Koni Marti <koni.marti@gmail.com>
Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'widgets/aerc.go')
-rw-r--r-- | widgets/aerc.go | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/widgets/aerc.go b/widgets/aerc.go index fffbf021..58956467 100644 --- a/widgets/aerc.go +++ b/widgets/aerc.go @@ -618,6 +618,33 @@ func (aerc *Aerc) Mailto(addr *url.URL) error { return nil } +func (aerc *Aerc) Mbox(source string) error { + acctConf := config.AccountConfig{} + if selectedAcct := aerc.SelectedAccount(); selectedAcct != nil { + acctConf = *selectedAcct.acct + info := fmt.Sprintf("Loading outgoing mbox mail settings from account [%s]", selectedAcct.Name()) + aerc.PushStatus(info, 10*time.Second) + aerc.Logger().Println(info) + } else { + acctConf.From = "<user@localhost>" + } + acctConf.Name = "mbox" + acctConf.Source = source + acctConf.Default = "INBOX" + acctConf.Archive = "Archive" + acctConf.Postpone = "Drafts" + acctConf.CopyTo = "Sent" + + mboxView, err := NewAccountView(aerc, aerc.conf, &acctConf, aerc.logger, aerc, nil) + if err != nil { + aerc.NewTab(errorScreen(err.Error(), aerc.conf.Ui), acctConf.Name) + } else { + aerc.accounts[acctConf.Name] = mboxView + aerc.NewTab(mboxView, acctConf.Name) + } + return nil +} + func (aerc *Aerc) CloseBackends() error { var returnErr error for _, acct := range aerc.accounts { |