author | Alberto Bertogli
<albertito@blitiri.com.ar> 2016-10-13 20:55:23 UTC |
committer | Alberto Bertogli
<albertito@blitiri.com.ar> 2016-10-21 21:18:53 UTC |
parent | a9ff0379a56d5658d4f2e3a7b7ee05e48d947aec |
internal/courier/procmail.go | +2 | -19 |
diff --git a/internal/courier/procmail.go b/internal/courier/procmail.go index a0d9188..d16ea53 100644 --- a/internal/courier/procmail.go +++ b/internal/courier/procmail.go @@ -56,29 +56,12 @@ func (p *Procmail) Deliver(from string, to string, data []byte) (error, bool) { defer cancel() cmd := exec.CommandContext(ctx, p.Binary, args...) - cmdStdin, err := cmd.StdinPipe() - if err != nil { - return tr.Errorf("StdinPipe: %v", err), true - } - + cmd.Stdin = bytes.NewReader(data) output := &bytes.Buffer{} cmd.Stdout = output cmd.Stderr = output - err = cmd.Start() - if err != nil { - return tr.Errorf("Error starting procmail: %v", err), true - } - - _, err = bytes.NewBuffer(data).WriteTo(cmdStdin) - if err != nil { - return tr.Errorf("Error sending data to procmail: %v", err), true - } - - cmdStdin.Close() - - err = cmd.Wait() - + err := cmd.Run() if ctx.Err() == context.DeadlineExceeded { return tr.Error(errTimeout), false }