3

I am working on a module in a large remote project in Codeigniter. My email function working only if I Change the below line

var $newline        = "\n";

from libraries/Email.php

To

var $newline        = "\r\n";

I changed this to avoid the MIME type error. My question is Will this affect the other mails which are already working?

It is not possible for me to contact all the remote developers. Any help could be appreciated.

Simba
  • 4,952
  • 3
  • 19
  • 29
Arun
  • 3,640
  • 7
  • 44
  • 87
  • 1
    Not sure about what `Email.php` has inside but please avoid composing email manually. It's almost impossible to get it right and it's not worth the effort. Any major third-party library you can find can do it for you. BTW, `var` belongs to the old PHP/4 OOP syntax, you should be using proper scope delimiters (public, protected, private). – Álvaro González Jun 16 '16 at 09:18
  • Using MS-Windows style line break sequences in plain text emails will lead to every second row being shown empty in all normal email clients on other operating systems. That looks horrible. – arkascha Jun 16 '16 at 09:20
  • 2
    In the RFC specification (https://tools.ietf.org/html/rfc2045) `\r\n` (CRLF) is the **correct** way to terminate line endings in **MIME headers** - however certain mail servers, such as Postfix, expect to receive the terminators as those native to the OS, it then deals with setting the actual line endings when it builds the email. So it depends on if these are line endings for MIME headers or in the email content and what mail server is actually doing the send. – CD001 Jun 16 '16 at 09:43
  • The line of code you quoted: is it part of CodeIgniter or your own code? There certainly shouldn't be a need to change code within CI; after all, it's a well-known framework that is used in production by a lot of sites; if it had something as fundamentally wrong with it as that, people would have noticed by now. A little more context might help though. How are you using the Email class? Perhaps you're using it wrong? What version of CI are you using? Do you need to upgrade? – Simba Jun 16 '16 at 10:11
  • @Simba, It is a very old project running in CI 1.7.2. The issue may be due to that. – Arun Jun 16 '16 at 10:20

1 Answers1

1

The Question has nothing to Do with codeigniter standards in conclusion of read below, and answer to your question should be NO it should not create problems for other mails that are already working You could test it across browsers

'\n' writes a newline in UNIX while for Windows there is the two character sequence: '\r\n'

There is a more detailed answer here Difference between \n and \r?

For example, on Windows, writing the character '\n' actually outputs the two- character sequence '\r\n' (and when reading the file back, '\r\n' is translated back into a single '\n' character).

Community
  • 1
  • 1
ShaH
  • 140
  • 8