Real Software Forums
http://forums.realsoftware.com/

Sending endofline via HTTPSocket.Get
http://forums.realsoftware.com/viewtopic.php?f=2&t=48031
Page 1 of 1

Author:  dgdavidge [ Fri May 31, 2013 5:11 pm ]
Post subject:  Sending endofline via HTTPSocket.Get

Having experienced a lot of trouble sending emails with RS, mostly due to ISPs blocking ports 25 and 587, I wrote a PHP program that gets the email address, subject and body via HTTPSocket.Get from my RS program. It works fine except that my attempts to force a linefeed in the body have all failed. I have tried:

1. Using the RS EndOfLine in the body. Result is the PHP programs reports the message was not sent.

2. Using \n in the body. This works in PHP scripts I have written for sending emails, but in this case, it just prints the \n as part of the message rather than as a line feed/carriage return.

3. Using %0d in the body. This seems a natural since I have to use %20 in place of all the spaces between words. It works if I copy the URL string to the clipboard and paste it into my browser. However it does not work if the same URL string is sent from RS with the HTTPSocket.Get function. The result is the email address and subject are sent, but the body of the email is blank. I suspect that RS is sensing the %0d (the ASCII carriage return character) as the end of the message. I also tried %0a, the ASCII line feed character, with the same results.

Does anyone have a suggestion as to how to get around this problem?

Author:  charonn0 [ Fri May 31, 2013 6:49 pm ]
Post subject:  Re: Sending endofline via HTTPSocket.Get

Just a guess, but try using EndOfLine.Unix in places you need the \n (0x0A) character.

Author:  msssltd [ Mon Jun 03, 2013 8:11 am ]
Post subject:  Re: Sending endofline via HTTPSocket.Get

dgdavidge wrote:
3. Using %0d in the body.
Is unlikely to work, because 0x0D is the return character, not the linefeed 0x0A (%0A) which just about all servers recognise as a line end terminator.

Most pertinent RFCs I have read specify \r\n as the preferred line ending, with an advisory that \n should also be recognised by server applications. Sadly, not all developers find time to read RFCs and there are plenty of Windows servers which only recognise \r\n.

Whatever platform you compile on, using endofline.windows in your client applications, should provide maximum compatibility with both Windows and Nix servers.

Author:  dgdavidge [ Mon Jun 03, 2013 6:26 pm ]
Post subject:  Re: Sending endofline via HTTPSocket.Get

I finally got it to work using %0a@0d. In fact it gave me a double line feed. Why %0a and %0d did nothing mystifies me. Any version of EndOfLine, whether plain, .UNIX or .windows caused the PHP program to fail and not send the email at all. Thanks for your help.

Author:  msssltd [ Tue Jun 04, 2013 1:30 am ]
Post subject:  Re: Sending endofline via HTTPSocket.Get

dgdavidge wrote:
I finally got it to work using %0a@0d. In fact it gave me a double line feed. Why %0a and %0d did nothing mystifies me.

Have you tried %0d%0a, in that order. An end of line is specifically \r\n (0x0d0a) and not \n\r (0x0a0d).

Quote:
Any version of EndOfLine, whether plain, .UNIX or .windows caused the PHP program to fail and not send the email at all.
PHP is embedded (transported) within HTML, so whatever you send to the PHP processor must conform to the HTML protocol. Whitespace characters have little meaning within HTML.

EndOfLine.Windows equates to a string of the two bytes 0x0d, 0x0A, Which are whitespace ASCII characters, ignored by the HTML parser. Sending the string "%0a%0d", takes 6 bytes but it informs the HTML parser that it needs to substitute the binary bytes (0x0a0d). Similarly "%22" will substitute double quotes, "%09" will substitute a tab character, etc etc.

Sorry if I did not make it clear that you would need to send the line ending sequence as in a way the PHP processor can recognise.

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/