summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2022-01-06 00:43:45 +0000
committerGitHub <noreply@github.com>2022-01-06 01:43:45 +0100
commit1514e13bb86d4714550107efa58c947b1bfc39c6 (patch)
treed6e1d1cf2543b48b4412f19c80ca76f444e48c3a /services
parentbf7b083cfe47cc922090ce7922b89f7a5030a44d (diff)
downloadgitea-1514e13bb86d4714550107efa58c947b1bfc39c6.tar.gz
gitea-1514e13bb86d4714550107efa58c947b1bfc39c6.zip
Add option to convert CRLF to LF line endings for sendmail (#18075)
It appears that several versions of sendmail require that the mail is sent to them with LF line endings instead of CRLF endings - which of course they will then convert back to CRLF line endings to comply with the SMTP standard. This PR adds another setting SENDMAIL_CONVERT_CRLF which will pass the message writer through a filter. This will filter out and convert CRLFs to LFs before writing them out to sendmail. Fix #18024 Signed-off-by: Andrew Thornton <art27@cantab.net>
Diffstat (limited to 'services')
-rw-r--r--services/mailer/mailer.go11
1 files changed, 9 insertions, 2 deletions
diff --git a/services/mailer/mailer.go b/services/mailer/mailer.go
index eac2b15c3c..e5e6272f10 100644
--- a/services/mailer/mailer.go
+++ b/services/mailer/mailer.go
@@ -290,13 +290,20 @@ func (s *sendmailSender) Send(from string, to []string, msg io.WriterTo) error {
return err
}
- _, err = msg.WriteTo(pipe)
+ if setting.MailService.SendmailConvertCRLF {
+ buf := &strings.Builder{}
+ _, err = msg.WriteTo(buf)
+ if err == nil {
+ _, err = strings.NewReplacer("\r\n", "\n").WriteString(pipe, buf.String())
+ }
+ } else {
+ _, err = msg.WriteTo(pipe)
+ }
// we MUST close the pipe or sendmail will hang waiting for more of the message
// Also we should wait on our sendmail command even if something fails
closeError = pipe.Close()
waitError = cmd.Wait()
-
if err != nil {
return err
} else if closeError != nil {