From 98ecd08e838862d4bbb347f558509185940c9d07 Mon Sep 17 00:00:00 2001 From: Drew Sullivan Date: Fri, 20 Nov 2015 15:18:50 -0500 Subject: [PATCH 1/3] Fixed runtime error: slice bounds out of range https://github.com/mailhog/mhsendmail/issues/5 --- cmd/cmd.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cmd/cmd.go b/cmd/cmd.go index b8860ef..251dcfd 100644 --- a/cmd/cmd.go +++ b/cmd/cmd.go @@ -69,6 +69,12 @@ func Go() { // provided on the command line. re := regexp.MustCompile("(?im)^To: (.*)\r\n$") n := bytes.IndexByte(body, 0) + var bodyStr string; + if n < 0 { + bodyStr = string(body) + } else { + bodyStr = string(body[:n]) + } bodyStr := string(body[:n]) includedRecip := re.FindAllString(bodyStr, -1) if includedRecip == nil { From 59a115ca938806013691b79b98e4433188956bd8 Mon Sep 17 00:00:00 2001 From: Drew Sullivan Date: Fri, 20 Nov 2015 15:20:23 -0500 Subject: [PATCH 2/3] PHP mail() function triggers 'missing recipient' message https://github.com/mailhog/mhsendmail/issues/3 The re for find To: doesn't work correctly Here is a fix. --- cmd/cmd.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/cmd.go b/cmd/cmd.go index 251dcfd..96f94d9 100644 --- a/cmd/cmd.go +++ b/cmd/cmd.go @@ -67,7 +67,8 @@ func Go() { if len(recip) == 0 { // We only need to parse the message to get a recipient if none where // provided on the command line. - re := regexp.MustCompile("(?im)^To: (.*)\r\n$") +// re := regexp.MustCompile("(?im)^To: (.*)\r*\n$") + re := regexp.MustCompile("(?im)^To: (.*)\r*$") n := bytes.IndexByte(body, 0) var bodyStr string; if n < 0 { @@ -75,7 +76,6 @@ func Go() { } else { bodyStr = string(body[:n]) } - bodyStr := string(body[:n]) includedRecip := re.FindAllString(bodyStr, -1) if includedRecip == nil { fmt.Fprintln(os.Stderr, "missing recipient") From b5db9e0b41337268e7fbf32028369159c8e5e1f6 Mon Sep 17 00:00:00 2001 From: Drew Sullivan Date: Fri, 20 Nov 2015 15:27:59 -0500 Subject: [PATCH 3/3] Added note for linux php.ini file --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index 2ba126d..1f22ce2 100644 --- a/README.md +++ b/README.md @@ -33,8 +33,16 @@ Or override the destination SMTP server: ./mhsendmail -smtp-addr "localhost:1026" test@mailhog.local ... ``` +To use from php.ini + +``` +sendmail_path = /usr/local/bin/mhsendmail +``` + ### Licence Copyright ©‎ 2015, Ian Kent (http://iankent.uk) Released under MIT license, see [LICENSE](LICENSE.md) for details. + +