diff --git a/msg.go b/msg.go index fe18a6e..e43a08b 100644 --- a/msg.go +++ b/msg.go @@ -547,7 +547,10 @@ func (m *Msg) WriteToSendmailWithContext(ctx context.Context, sp string, a ...st return fmt.Errorf("sendmail command failed: %s", serr) } - // Wait for completion or cancellation of the sendmail executable + // Close STDIN and wait for completion or cancellation of the sendmail executable + if err := si.Close(); err != nil { + return fmt.Errorf("failed to close STDIN pipe: %w", err) + } if err := ec.Wait(); err != nil { return fmt.Errorf("sendmail command execution failed: %w", err) }