Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2024-11

help with NNTP posting

4 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

duilio foschi

I cannot understand how I can post a message into a newsgroup using INet components.

I can connect, authenticate, join a group and issue several commands like ARTICLE
BODY
HEAD
XOVER

However, when I try to post a message, my code always returns 500 (unknown command or wrong syntax).

Any help?

This is what I do (after connecting and authenticating):

uses
...lNet, lclnet, lnetcomponents, LConvEncoding;
var
   aStream:TMemoryStream;      // correctly initialized elsewhere
   aclient:TLTCPComponent;     // correctly initialized elsewhere
procedure LineToStream(Buf : String);
begin
   Buf := Buf + #13#10;
   aStream.WriteBuffer(Buf[1], Length(Buf));
end;
procedure TfrmUReader.btnSendPostClick(Sender: TObject);
var
   a:integer;
begin
   aStream.Clear;
   LineToStream('POST');
   LineToStream('"peppepolpo" ');
   LineToStream('Newsgroups: it.hobby.fai-da-te');
   LineToStream('Subject: test 201937');
   LineToStream('Organization: None');
   LineToStream('X-Newsreader: DIY component ');
   { End of header is a blank line }
   LineToStream('');
   { Write the message body }
   LineToStream('');
   LineToStream('test 201937');
   aStream.Seek(0, soFromBeginning );
   a:=aclient.Send(aStream, aStream.Size);
   // a=500 here

end;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20241119/2fcb211b/attachment.htm>

Reply by email

Marcus Sackrow
to duilio foschi

Hi,

duilio foschi wrote
I cannot understand how I can post a message into a newsgroup using INet components.

I am not 100% sure but as far as I remember you need to send a single "POST" command first check the return code if you are even allowed to post

and then sent the Header and Content

Show quoted text 19 lines
uses ...lNet, lclnet, lnetcomponents, LConvEncoding; var ? ?aStream:TMemoryStream; ? ? ?// correctly initialized elsewhere ? ?aclient:TLTCPComponent; ? ? // correctly initialized elsewhere procedure LineToStream(Buf : String); begin ? ?Buf := Buf + #13#10; ? ?aStream.WriteBuffer(Buf[1], Length(Buf)); end; procedure TfrmUReader.btnSendPostClick(Sender: TObject); var ? ?a:integer; begin ? ?aStream.Clear; ? ?LineToStream('POST');
 ???? aStream.Position := 0;
 ??? a:=aclient.Send(aStream, aStream.Size);
 ??? if a = 340 then

??? begin

 ?????? aStream.Clear;
Show quoted text 12 lines
? ?LineToStream('"peppepolpo" '); ? ?LineToStream('Newsgroups: it.hobby.fai-da-te'); ? ?LineToStream('Subject: test 201937'); ? ?LineToStream('Organization: None'); ? ?LineToStream('X-Newsreader: DIY component '); ? ?{ End of header is a blank line } ? ?LineToStream(''); ? ?{ Write the message body } ? ?LineToStream(''); ? ?LineToStream('test 201937');
 ? ?? LineToStream('.'); // End the message with a single point
Show quoted text 8 lines
? ?aStream.Seek(0, soFromBeginning ); ? ?a:=aclient.Send(aStream, aStream.Size); ? ?// a=500 here end;

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20241120/bb38a5dd/attachment-0001.htm>

Reply by email

duilio foschi
to Marcus Sackrow

solved.

from

https://www.w3.org/Protocols/rfc977/rfc977.html

3.10. The POST command
...

The text forming the header and body of the message to be posted should be sent by the client using the conventions for text received from the news server: A single period (".") on a line indicates the end of the text, with lines starting with a period in the original text having that period doubled during transmission.

This code works ok:

var
alist:TStringlist // initialized elsewhere
   alist.Clear;
   aList.Add('POST');
   aList.Add('From: "peppepolpo" ');
   aList.Add('Newsgroups: it.hobby.fai-da-te');
   aList.Add('Subject: test 201937');
   aList.Add('Organization: None');
   aList.Add('X-Newsreader: DIY component ');
   { End of header is a blank line }
   aList.Add('');
   { Write the message body }
   aList.Add('');
   aList.Add('test 201937');
   aList.Add('.');   // <<<<<<<<<<<<<<<<<<<<<<<<<<<  this was missing!
   a:=aclient.SendMessage(alist.Text);

On Wed, Nov 20, 2024 at 8:37?AM Marcus Sackrow via lazarus <

Show quoted text 16 lines
wrote: Am 20.11.2024 um 08:34 schrieb Marcus Sackrow via lazarus: >> LineToStream('"peppepolpo" '); >> just noticed here is also the 'From:' missing! LineToStream('From: "peppepolpo" '); -- _______________________________________________ lazarus mailing list https://lists.lazarus-ide.org/listinfo/lazarus

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20241120/9027f0ff/attachment.htm>

Reply by email