aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--commands/compose/send.go49
-rw-r--r--doc/aerc.1.scd4
2 files changed, 37 insertions, 16 deletions
diff --git a/commands/compose/send.go b/commands/compose/send.go
index 6e104529..cd964d70 100644
--- a/commands/compose/send.go
+++ b/commands/compose/send.go
@@ -17,6 +17,7 @@ import (
"github.com/pkg/errors"
"git.sr.ht/~rjarry/aerc/app"
+ "git.sr.ht/~rjarry/aerc/commands"
"git.sr.ht/~rjarry/aerc/commands/mode"
"git.sr.ht/~rjarry/aerc/lib"
"git.sr.ht/~rjarry/aerc/log"
@@ -36,23 +37,28 @@ func (Send) Aliases() []string {
return []string{"send"}
}
+func (Send) Options() string {
+ return "a:t:"
+}
+
+func (s Send) CompleteOption(r rune, term string) []string {
+ if r == 't' {
+ return commands.GetFolders([]string{term})
+ }
+ return nil
+}
+
func (Send) Complete(args []string) []string {
return nil
}
-func (Send) Execute(args []string) error {
- opts, optind, err := getopt.Getopts(args, "a:")
+func (s Send) Execute(args []string) error {
+ opts, optind, err := getopt.Getopts(args, s.Options())
if err != nil {
return err
}
if optind != len(args) {
- return errors.New("Usage: send [-a <flat|year|month>]")
- }
- var archive string
- for _, opt := range opts {
- if opt.Option == 'a' {
- archive = opt.Value
- }
+ return errors.New("Usage: send [-a <flat|year|month>] [-t <folder>")
}
tab := app.SelectedTab()
if tab == nil {
@@ -60,8 +66,20 @@ func (Send) Execute(args []string) error {
}
composer, _ := tab.Content.(*app.Composer)
tabName := tab.Name
+
config := composer.Config()
+ var copyto string = config.CopyTo
+ var archive string
+ for _, opt := range opts {
+ if opt.Option == 'a' {
+ archive = opt.Value
+ }
+ if opt.Option == 't' {
+ copyto = opt.Value
+ }
+ }
+
outgoing, err := config.Outgoing.ConnectionString()
if err != nil {
return errors.Wrap(err, "ReadCredentials(outgoing)")
@@ -103,6 +121,7 @@ func (Send) Execute(args []string) error {
from: config.From,
rcpts: rcpts,
domain: domain,
+ copyto: copyto,
}
log.Debugf("send config uri: %s", ctx.uri)
@@ -161,7 +180,6 @@ func send(composer *app.Composer, ctx sendCtx,
mode.NoQuit()
var copyBuf bytes.Buffer // for the Sent folder content if CopyTo is set
- config := composer.Config()
failCh := make(chan error)
// writer
@@ -191,7 +209,7 @@ func send(composer *app.Composer, ctx sendCtx,
var writer io.Writer = sender
- if config.CopyTo != "" && ctx.scheme != "jmap" {
+ if ctx.copyto != "" && ctx.scheme != "jmap" {
writer = io.MultiWriter(writer, &copyBuf)
}
err = composer.WriteMessage(header, writer)
@@ -215,15 +233,15 @@ func send(composer *app.Composer, ctx sendCtx,
app.NewTab(composer, tabName)
return
}
- if config.CopyTo != "" && ctx.scheme != "jmap" {
- app.PushStatus("Copying to "+config.CopyTo, 10*time.Second)
- errch := copyToSent(composer.Worker(), config.CopyTo,
+ if ctx.copyto != "" && ctx.scheme != "jmap" {
+ app.PushStatus("Copying to "+ctx.copyto, 10*time.Second)
+ errch := copyToSent(composer.Worker(), ctx.copyto,
copyBuf.Len(), &copyBuf)
err = <-errch
if err != nil {
errmsg := fmt.Sprintf(
"message sent, but copying to %v failed: %v",
- config.CopyTo, err.Error())
+ ctx.copyto, err.Error())
app.PushError(errmsg)
composer.SetSent(archive)
composer.Close()
@@ -255,6 +273,7 @@ type sendCtx struct {
from *mail.Address
rcpts []*mail.Address
domain string
+ copyto string
}
func newSendmailSender(ctx sendCtx) (io.WriteCloser, error) {
diff --git a/doc/aerc.1.scd b/doc/aerc.1.scd
index d981e014..40cda9a1 100644
--- a/doc/aerc.1.scd
+++ b/doc/aerc.1.scd
@@ -688,13 +688,15 @@ message list, the message in the message viewer, etc).
specified is a directory or ends in _/_, aerc will use the attachment filename
if available or a generated name if not.
-*:send* [*-a* _<scheme>_]
+*:send* [*-a* _<scheme>_] [*-t* _<folder>_]
Sends the message using this accounts default outgoing transport
configuration. For details on configuring outgoing mail delivery consult
*aerc-accounts*(5).
*-a*: Archive the message being replied to. See *:archive* for schemes.
+ *-t*: Overrides the Copy-To folder for saving the message.
+
*:switch-account* _<account-name>_++
*:switch-account* *-n*++
*:switch-account* *-p*