[1.7.x] Fixed #23063 -- Convert \n and \r to \r\n when using the SMTP backend as per RFC.

Backport of 8d789449c7861b8cf8b10d244f26d9d354989aaf from master.