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
1 changed files with 9 additions and 2 deletions

View File

@ -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
}