propagate error from sendmail

This commit is contained in:
y0ast 2020-09-20 22:53:44 +01:00 committed by Reto Brunner
parent 8bf100f7b4
commit 42ce6b41ff

View file

@ -231,10 +231,17 @@ func (Send) Execute(aerc *widgets.Aerc, args []string) error {
if err != nil { if err != nil {
return 0, errors.Wrap(err, "cmd.StdinPipe") return 0, errors.Wrap(err, "cmd.StdinPipe")
} }
defer wc.Close() err = cmd.Start()
go cmd.Run() if err != nil {
return 0, errors.Wrap(err, "cmd.Start")
}
ctr := datacounter.NewWriterCounter(wc) ctr := datacounter.NewWriterCounter(wc)
composer.WriteMessage(header, ctr) 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 return int(ctr.Count()), nil
} }