Newsgroups : Borland : borland.public.delphi.internet.winsock : 2007 Apr : Re: connect to mailserver with TidTelnet, LastCmdResult
| Subject: | Re: connect to mailserver with TidTelnet, LastCmdResult |
| Posted by: | "Peter Gustafsson" (sm5triatpassagendotse) |
| Date: | Mon, 16 Apr 2007 00:21:23 |
Hi, thanks.
I need to monitor exactly what ansver I get after each SMTP command.
Can I do that with TidSMTP?
But I changed to TidTCPClient, I get the server greeting but I have to
read LastCmdResult before the first sendCmd to get it.
Now I have problem sending text to the server.
With TidTelnet I could use SendCh, using SendCmd doesn't work.
I send DATA, and try to send some text.
// Peter
"Remy Lebeau (TeamB)" <no.spam@no.spam.com> skrev i meddelandet
news:46212e28$1@newsgroups.borland.com...
>
> "Peter Gustafsson" <sm5triATpassagenDOTse> wrote in message
> news:46204ed2$1@newsgroups.borland.com...
>
>> I'm trying to connect to a mailserver(smtp) with Indy TidTelnet.
>
> Why are you using TIdTelnet for that? You should be using TIdSMTP
> instead.
>
>> I having problem getting right response message from server.
>
> That is because you can't use SendCmd() with TIdTelnet. TIdTelnet has
> an internal reading thread that will interfer with SendCmd()'s own
> reading. If you want to handle the SMTP commands manually and not use
> TIdSMTP, then you need to use TIdTCPClient directly instead. I do not
> recommend using TIdTelnet for this at all.
>
>> What I missing is the server greetings when I connect to the mail
>> server: 220 Symantec Mail Security Sat, 11 Apr 2004 15:39:14 +0200
>
> You need to call GetResponse() after Connect() exits before you then
> send your first command, ie:
>
> TCPClient.Connect;
> TCPClient.GetResponse(220);
> TCPClient.SendCmd('HELO test.se');
>
>> Sometime all LastCmdResult is of by one. I mean Connection
>> greetings show after HELO cmd.
>
> That is because you did not read the server's greeting when
> connecting, so it is still pending when you call SendCmd().
>
> Again, you really should be using TIdSMTP instead. It handles all of
> this for you.
>
>
> Gambit