From 070eb39132e0bc155f5be5fc593dc5560f66cd96 Mon Sep 17 00:00:00 2001 From: Winni Neessen Date: Wed, 25 May 2022 10:46:50 +0200 Subject: [PATCH 1/2] Address #5 For the WriteToSendmail* methods the STDIN pipe should be closed so that a forced EOF is sent to the sending program --- msg.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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) } From fa7066c9cf7f527dd0725e7025d58aa469480e77 Mon Sep 17 00:00:00 2001 From: Winni Neessen Date: Wed, 25 May 2022 10:53:37 +0200 Subject: [PATCH 2/2] Update path to sendmail binary On most systems sendmail is located in /usr/sbin not /usr/bin --- msg.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/msg.go b/msg.go index e43a08b..7367ed6 100644 --- a/msg.go +++ b/msg.go @@ -58,7 +58,7 @@ type Msg struct { } // SendmailPath is the default system path to the sendmail binary -const SendmailPath = "/usr/bin/sendmail" +const SendmailPath = "/usr/sbin/sendmail" // MsgOption returns a function that can be used for grouping Msg options type MsgOption func(*Msg)