forked from forgejo/forgejo
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>
This commit is contained in:
parent
bf7b083cfe
commit
1514e13bb8
4 changed files with 20 additions and 7 deletions
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue