Discussion:
Problem with TidSMTP : socket error 10054
(too old to reply)
ilvi
2006-04-14 12:17:01 UTC
Permalink
Hi.

I have small console program which send some text data from file
(size of file approximately 13 KB).
When i run this program on Comp1 in my network all work.
When i run this program on Comp2 in the same newtork i have two
different case :
1) If i send this data by TIdAttachment then all work normally.
2) If i send this daba through TidMessage.Body then mail don't send
with socket error 10054.

Comp2 have the same network settings as a Comp1. All needs port open.

Plese, help find solution in case №2.
P.S. sorry for my english.

Text of program:

uses
SysUtils, IdSMTP, IdMessage, IdAntiFreeze;
var
iCount : integer;
FRecepientAdress : String; //1
FFilePath : String; //2
FSMTPServer : String; //3
FSMTPPort : integer; //4
FAuthType : integer; //5
FSMTPAccount : String; //6
FSMTPLogin : String; //7
FSubject : String; //8

ClientSMTP : TIdSMTP;
IdMsgSend : TidMessage;
idAnti : TidAntiFreeze;
begin
iCount := ParamCount;
if(iCount < 2) then
begin
WriteLN('Not enought param. Exit.');
Exit;
end;

FRecepientAdress := '***@domen.ru';
FSMTPServer := 'smtp.domen.ru';
FSMTPPort := 25;
FAuthType := 1;
FSMTPAccount := 'name';
FSMTPLogin := 'password';
FFilePath := 'c:\temp\1.txt';
FSubject := 'subject';


FRecepientAdress := ParamStr(1);
FFilePath := ParamStr(2);

try
idAnti := TIdAntiFreeze.Create(nil);
ClientSMTP := TIdSMTP.Create(Nil);
IdMsgSend := TIdMessage.Create(ClientSMTP);

ClientSMTP.Host := FSMTPServer;
ClientSMTP.Port := FSMTPPort;
ClientSMTP.UserId := FSMTPAccount;
ClientSMTP.Password := FSMTPLogin;
if(FAuthType = 0) then
ClientSMTP.AuthenticationType := atNone
else
ClientSMTP.AuthenticationType := atLogin;

IdMsgSend.Body.Clear;

IdMsgSend.From.Text := FSMTPAccount + '@domen.ru';
with IdMsgSend.Recipients.Add do begin
Address := FRecepientAdress;
Name := 'Some Name';
end;

IdMsgSend.Subject := FSubject;
IdMsgSend.ReceiptRecipient.Text := '';


IdMsgSend.Body.LoadFromFile(FFilePath);
//TIdAttachment.Create(IdMsgSend.MessageParts, FFilePath);

ClientSMTP.Connect;

if ClientSMTP.Connected then
begin
ClientSMTP.Send(IdMsgSend);
ClientSMTP.Disconnect;
end;
except
WriteLN('Error.');
end;

if(IdMsgSend <> nil) then
IdMsgSend.Free;

if(ClientSMTP <> nil) then
ClientSMTP.Free;

if(idAnti <> nil) then
idAnti.Free;
end.



--- posted by geoForum on http://delphi.newswhat.com
Remy Lebeau (TeamB)
2006-04-14 18:32:37 UTC
Permalink
Post by ilvi
I have small console program which send some text data from file
(size of file approximately 13 KB).
What does the actual contents of the file look like?
Post by ilvi
IdMsgSend.Body.Clear;
You don't need to Clear() the message. It is already clear when it is
created.
Post by ilvi
IdMsgSend.Body.LoadFromFile(FFilePath);
You did not set the TIdMessage's ContentType property to anything. You must
do that so that the received knows the type of data being received. I would
also suggest that you set the NoEncode property to True before sending the
message, so that the Body text is sent as-is without any additional encoding
on Indy's part.


Gambit
ilvi
2006-04-21 13:06:48 UTC
Permalink
Post by Remy Lebeau (TeamB)
What does the actual contents of the file look like?
It's just many numbers.
Post by Remy Lebeau (TeamB)
Post by ilvi
IdMsgSend.Body.LoadFromFile(FFilePath);
It's string for debug. Actually text taken from database.
Post by Remy Lebeau (TeamB)
Gambit
All work normal. I'll find problem - it's error in driver of LanCard.
Thanks for answer.



--- posted by geoForum on http://delphi.newswhat.com

Loading...