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. + + diff --git a/cmd/cmd.go b/cmd/cmd.go index b8860ef..96f94d9 100644 --- a/cmd/cmd.go +++ b/cmd/cmd.go @@ -67,9 +67,15 @@ 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) - bodyStr := string(body[:n]) + var bodyStr string; + if n < 0 { + bodyStr = string(body) + } else { + bodyStr = string(body[:n]) + } includedRecip := re.FindAllString(bodyStr, -1) if includedRecip == nil { fmt.Fprintln(os.Stderr, "missing recipient")