diff --git a/commands/compose/send.go b/commands/compose/send.go index a3047ddf..7fd1971b 100644 --- a/commands/compose/send.go +++ b/commands/compose/send.go @@ -192,12 +192,15 @@ func sendHelper(composer *app.Composer, header *mail.Header, uri *url.URL, domai go func() { defer log.PanicHandler() - var parentDir string + var folders []string + if copyTo != "" { + folders = append(folders, copyTo) + } if copyToReplied && composer.Parent() != nil { - parentDir = composer.Parent().Folder + folders = append(folders, composer.Parent().Folder) } sender, err := send.NewSender( - composer.Worker(), uri, domain, from, rcpts, parentDir) + composer.Worker(), uri, domain, from, rcpts, folders) if err != nil { failCh <- errors.Wrap(err, "send:") return diff --git a/commands/msg/bounce.go b/commands/msg/bounce.go index 819595cc..3b093ab4 100644 --- a/commands/msg/bounce.go +++ b/commands/msg/bounce.go @@ -159,7 +159,7 @@ func (b Bounce) Execute(args []string) error { msg.Envelope.MessageId, addresses) if sender, err = send.NewSender(acct.Worker(), uri, - domain, config.From, rcpts, ""); err != nil { + domain, config.From, rcpts, nil); err != nil { return } defer func() { diff --git a/lib/send/jmap.go b/lib/send/jmap.go index 5f679b43..0f6fea12 100644 --- a/lib/send/jmap.go +++ b/lib/send/jmap.go @@ -11,7 +11,7 @@ import ( func newJmapSender( worker *types.Worker, from *mail.Address, rcpts []*mail.Address, - copyTo string, + copyTo []string, ) (io.WriteCloser, error) { var writer io.WriteCloser done := make(chan error) diff --git a/lib/send/sender.go b/lib/send/sender.go index 87ca4745..a0b008db 100644 --- a/lib/send/sender.go +++ b/lib/send/sender.go @@ -16,7 +16,7 @@ import ( func NewSender( worker *types.Worker, uri *url.URL, domain string, from *mail.Address, rcpts []*mail.Address, - copyTo string, + copyTo []string, ) (io.WriteCloser, error) { protocol, auth, err := parseScheme(uri) if err != nil { diff --git a/worker/jmap/send.go b/worker/jmap/send.go index 2fbb8aed..ee626357 100644 --- a/worker/jmap/send.go +++ b/worker/jmap/send.go @@ -71,8 +71,11 @@ func (w *JMAPWorker) handleStartSend(msg *types.StartSendingMessage) error { w.rolePatch(mailbox.RoleSent): true, w.rolePatch(mailbox.RoleDrafts): nil, } - if copyTo := w.dir2mbox[msg.CopyTo]; copyTo != "" { - onSuccess[w.mboxPatch(copyTo)] = true + for _, dir := range msg.CopyTo { + mbox, ok := w.dir2mbox[dir] + if ok && mbox != w.roles[mailbox.RoleSent] { + onSuccess[w.mboxPatch(mbox)] = true + } } // Create the submission req.Invoke(&emailsubmission.Set{ diff --git a/worker/types/messages.go b/worker/types/messages.go index 0d0a187a..0174b544 100644 --- a/worker/types/messages.go +++ b/worker/types/messages.go @@ -226,7 +226,7 @@ type StartSendingMessage struct { Message From *mail.Address Rcpts []*mail.Address - CopyTo string + CopyTo []string } // Messages