aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/aerc.go
diff options
context:
space:
mode:
authorKoni Marti <koni.marti@gmail.com>2022-07-27 13:34:46 +0200
committerRobin Jarry <robin@jarry.cc>2022-08-01 12:26:29 +0200
commit903d436ab8c3a83ebd3972650312b9b72e1d49bc (patch)
tree41169311c1b091e230230fedc9d397982db7601d /widgets/aerc.go
parentaaf0a0c65673db4b94c0dc200d7394a192128da1 (diff)
downloadaerc-903d436ab8c3a83ebd3972650312b9b72e1d49bc.tar.gz
mailto: add account query parameter
Specify an account parameter in the mailto argument. If not specified, the selected account is used as default. Example: $ aerc 'mailto:user@host?account=Fastmail' Suggested-by: staceee 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.go19
1 files changed, 14 insertions, 5 deletions
diff --git a/widgets/aerc.go b/widgets/aerc.go
index 90e7a9e5..fb80c391 100644
--- a/widgets/aerc.go
+++ b/widgets/aerc.go
@@ -532,13 +532,9 @@ func (aerc *Aerc) RegisterChoices(choices []Choice) {
}
func (aerc *Aerc) Mailto(addr *url.URL) error {
- acct := aerc.SelectedAccount()
- if acct == nil {
- return errors.New("No account selected")
- }
-
var subject string
var body string
+ var acctName string
h := &mail.Header{}
to, err := mail.ParseAddressList(addr.Opaque)
if err != nil && addr.Opaque != "" {
@@ -547,6 +543,8 @@ func (aerc *Aerc) Mailto(addr *url.URL) error {
h.SetAddressList("to", to)
for key, vals := range addr.Query() {
switch strings.ToLower(key) {
+ case "account":
+ acctName = strings.Join(vals, "")
case "bcc":
list, err := mail.ParseAddressList(strings.Join(vals, ","))
if err != nil {
@@ -578,6 +576,17 @@ func (aerc *Aerc) Mailto(addr *url.URL) error {
}
}
+ acct := aerc.SelectedAccount()
+ if acctName != "" {
+ if a, ok := aerc.accounts[acctName]; ok && a != nil {
+ acct = a
+ }
+ }
+
+ if acct == nil {
+ return errors.New("No account selected")
+ }
+
composer, err := NewComposer(aerc, acct, aerc.Config(),
acct.AccountConfig(), acct.Worker(), "", h, models.OriginalMail{})
if err != nil {