From 42ce6b41ff7ff56f89de25e4807ab30c6eef4662 Mon Sep 17 00:00:00 2001
From: y0ast <joost@joo.st>
Date: Sun, 20 Sep 2020 22:53:44 +0100
Subject: propagate error from sendmail

---
 commands/compose/send.go | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

(limited to 'commands')

diff --git a/commands/compose/send.go b/commands/compose/send.go
index dd7ece9..abbcb54 100644
--- a/commands/compose/send.go
+++ b/commands/compose/send.go
@@ -231,10 +231,17 @@ func (Send) Execute(aerc *widgets.Aerc, args []string) error {
 		if err != nil {
 			return 0, errors.Wrap(err, "cmd.StdinPipe")
 		}
-		defer wc.Close()
-		go cmd.Run()
+		err = cmd.Start()
+		if err != nil {
+			return 0, errors.Wrap(err, "cmd.Start")
+		}
 		ctr := datacounter.NewWriterCounter(wc)
 		composer.WriteMessage(header, ctr)
+		wc.Close() // force close to make sendmail send
+		err = cmd.Wait()
+		if err != nil {
+			return 0, errors.Wrap(err, "cmd.Wait")
+		}
 		return int(ctr.Count()), nil
 	}
 
-- 
cgit 1.4.1-2-gfad0