If I recall correctly there were some issues regarding line endings in headers, etc. a while ago. After that a new option was added:
// this string is used as a delimiter for message headers when sending $rcmail_config['mail_header_delimiter'] = "\r\n";
I just stumbled over an explanation why there is a need for different line endings (not sure if that was clarified yet).
The problem is that the behavior of mail() is different on Windows and Unix systems. On Windows mail() connects to an SMTP server to send, while on Unix it usually uses a local command which then forwards the mail to the MTA of the system.
The result is that on Windows you need to use the line endings defined in the mail specification for headers and body: "\r\n"
Some MTAs will get a little confused when you use only "\n" on a Windows system. Especially good old friend qmail is very picky and will simply refuse mails without the needed \r.
On Unix the MTA usually uses a "sendmail interface" which assumes that it receives Unix line endings (\n) and will change them to "\r\n". So using a "\r\n" in this case will result in "\r\r\n" which of course is wrong. Instead we only need to use "\n" in mail().
Does anyone know how Macs send mail() (afaik they only use \r as line endings)?
Perhaps we can add some kind of autodetection with this info (but let the user override it if he has a special setup)?
Balu
Your facts here are right. I don't have anything to add, but this is an
issue that is always on the plate. A form of auto-detection would be great
and a good solution will provide great extensibility and put RC ahead of
other clients that don't cater for this platform dependant issue.
On Wed, 08 Mar 2006 22:16:57 +1100, Thomas -Balu- Walter
list+roundcube-dev@b-a-l-u.de wrote:
If I recall correctly there were some issues regarding line endings in headers, etc. a while ago. After that a new option was added:
// this string is used as a delimiter for message headers when sending $rcmail_config['mail_header_delimiter'] = "\r\n";
I just stumbled over an explanation why there is a need for different line endings (not sure if that was clarified yet).
The problem is that the behavior of mail() is different on Windows and Unix systems. On Windows mail() connects to an SMTP server to send, while on Unix it usually uses a local command which then forwards the mail to the MTA of the system.
The result is that on Windows you need to use the line endings defined in the mail specification for headers and body: "\r\n"
Some MTAs will get a little confused when you use only "\n" on a Windows system. Especially good old friend qmail is very picky and will simply refuse mails without the needed \r.
On Unix the MTA usually uses a "sendmail interface" which assumes that it receives Unix line endings (\n) and will change them to "\r\n". So using a "\r\n" in this case will result in "\r\r\n" which of course is wrong. Instead we only need to use "\n" in mail().
Does anyone know how Macs send mail() (afaik they only use \r as line endings)?
Perhaps we can add some kind of autodetection with this info (but let the user override it if he has a special setup)?
Balu
2006/3/8, Thomas -Balu- Walter list+roundcube-dev@b-a-l-u.de:
If I recall correctly there were some issues regarding line endings in headers, etc. a while ago. After that a new option was added:
// this string is used as a delimiter for message headers when sending $rcmail_config['mail_header_delimiter'] = "\r\n";
I just stumbled over an explanation why there is a need for different line endings (not sure if that was clarified yet).
The problem is that the behavior of mail() is different on Windows and Unix systems. On Windows mail() connects to an SMTP server to send, while on Unix it usually uses a local command which then forwards the mail to the MTA of the system.
The result is that on Windows you need to use the line endings defined in the mail specification for headers and body: "\r\n"
Some MTAs will get a little confused when you use only "\n" on a Windows system. Especially good old friend qmail is very picky and will simply refuse mails without the needed \r.
On Unix the MTA usually uses a "sendmail interface" which assumes that it receives Unix line endings (\n) and will change them to "\r\n". So using a "\r\n" in this case will result in "\r\r\n" which of course is wrong. Instead we only need to use "\n" in mail().
Does anyone know how Macs send mail() (afaik they only use \r as line endings)?
Perhaps we can add some kind of autodetection with this info (but let the user override it if he has a special setup)?
Balu
I'm not a skilled programmer .. but I guess IF autodetection would be implemented .. it should be a 'run once' - event. Since PHP is a scripting language .. we don't want to be autodetected every time the mail() function is invoked (=overhead). So i guess there should be set an 'on-first-run-only' variable in some database or text-file ?
On Wed, 08 Mar 2006 22:40:41 +1100, Sander boxtel@gmail.com wrote:
2006/3/8, Thomas -Balu- Walter list+roundcube-dev@b-a-l-u.de:
If I recall correctly there were some issues regarding line endings in headers, etc. a while ago. After that a new option was added:
// this string is used as a delimiter for message headers when sending $rcmail_config['mail_header_delimiter'] = "\r\n";
I just stumbled over an explanation why there is a need for different line endings (not sure if that was clarified yet).
The problem is that the behavior of mail() is different on Windows and Unix systems. On Windows mail() connects to an SMTP server to send, while on Unix it usually uses a local command which then forwards the mail to the MTA of the system.
The result is that on Windows you need to use the line endings defined in the mail specification for headers and body: "\r\n"
Some MTAs will get a little confused when you use only "\n" on a Windows system. Especially good old friend qmail is very picky and will simply refuse mails without the needed \r.
On Unix the MTA usually uses a "sendmail interface" which assumes that it receives Unix line endings (\n) and will change them to "\r\n". So using a "\r\n" in this case will result in "\r\r\n" which of course is wrong. Instead we only need to use "\n" in mail().
Does anyone know how Macs send mail() (afaik they only use \r as line endings)?
Perhaps we can add some kind of autodetection with this info (but let the user override it if he has a special setup)?
Balu
I'm not a skilled programmer .. but I guess IF autodetection would be implemented .. it should be a 'run once' - event. Since PHP is a scripting language .. we don't want to be autodetected every time the mail() function is invoked (=overhead). So i guess there should be set an 'on-first-run-only' variable in some database or text-file ?
Only problem with that is migration to a different server with a different
MTA or change of MTA on the current server.
Any auto-detect suggestions anyone?
On Wed, Mar 08, 2006 at 10:52:27PM +1100, Chris Fordham wrote:
Only problem with that is migration to a different server with a different
MTA or change of MTA on the current server. Any auto-detect suggestions anyone?
Untested:
// Try to autodetect operating system and use the correct line endings // form mails $rcmail_config['mail_header_delimiter'] = "\n"; if (strtolower(substr(PHP_OS, 0, 3)=='win')) $rcmail_config['mail_header_delimiter'] = "\r\n"; if (strtolower(substr(PHP_OS, 0, 3)=='mac')) // not sure about Macs - anyone? $rcmail_config['mail_header_delimiter'] = "\r";
// allow user to override if autodetection fails: // $rcmail_config['mail_header_delimiter'] = "\r\n";
Balu
On 8 Mar 2006, at 11:52, Chris Fordham wrote:
Only problem with that is migration to a different server with a
different MTA or change of MTA on the current server. Any auto-detect suggestions anyone?
The PHP_EOL constant has been available from 4.3.10 and 5.0.2.
php -r "print_r(get_defined_constants());" # List all defined constants
php -r "print(ord(PHP_EOL));" # For my Mac it's 10 (\n), probably
because of the unix core
Yours, Craig -- Craig Webster | t: +44 (0)131 516 8595 | e: craig@xeriom.net Xeriom.NET | f: +44 (0)131 661 0689 | w: http://xeriom.net
"Te audire non possum. Musa sapientum fixa est in aure" - Unknown
Macs should definitely use \n. All command-line, scripting, etc. on Mac uses the Unix standard \n for line endings.
The \r is only ever used by GUI programmes, and is really a left-over from OS 9 and before, where it was standard. Many OS X GUI programmes use the \n now too (e.g. TextEdit, the standard OS X text editor, saves with \n by default).
The PHP_EOL constant has been available from 4.3.10 and 5.0.2.
php -r "print_r(get_defined_constants());" # List all defined constants php -r "print(ord(PHP_EOL));" # For my Mac it's 10 (\n), probably
because of the unix core
-- iwan standley
Thomas -Balu- Walter wrote:
On Wed, Mar 08, 2006 at 10:52:27PM +1100, Chris Fordham wrote:
Only problem with that is migration to a different server with a different
MTA or change of MTA on the current server. Any auto-detect suggestions anyone?Untested:
// Try to autodetect operating system and use the correct line endings // form mails $rcmail_config['mail_header_delimiter'] = "\n"; if (strtolower(substr(PHP_OS, 0, 3)=='win')) $rcmail_config['mail_header_delimiter'] = "\r\n"; if (strtolower(substr(PHP_OS, 0, 3)=='mac')) // not sure about Macs - anyone? $rcmail_config['mail_header_delimiter'] = "\r";
I run RoundCube with "\r\n" on my Mac. Since it has a BSD/Unix core I guess it should also work with "\n". Will test that later on.
// allow user to override if autodetection fails: // $rcmail_config['mail_header_delimiter'] = "\r\n";
Balu
Regards, Thomas