views:

1020

answers:

3

I'm getting the error "SMTP incoming data timeout" when I try to send an email with inline images in Windows XP, I'm using the tiburon branch of Indy 10 with the following code to send emails with inline images:

   MB := TIdMessageBuilderHtml.Create;
    try
      MB.PlainText.Assign(Text);
      MB.Html.Assign(FHTML);
      MB.HtmlFiles.Add('c:\Path\to\My\Image.jpg');
      MB.FillMessage(IdMessage);
    finally
      MB.Free;
    end;


  if not IdSMTP.Connected then
    IdSMTP.Connect;
  IdSMTP.Send(IdMessage);

It just happens in Windows XP, in Windows Vista the email and the inline image are sent just fine.

Apparently it isn't sending anything to the server, it appears to become stuck enconding the image before sending.

Here is the call stack:

 IdReplySMTP        497   +1 TIdReplySMTP.RaiseReplyError
 IdTCPConnection    574   +1 TIdTCPConnection.RaiseExceptionForLastCmdResult
 IdTCPConnection    724  +10 TIdTCPConnection.CheckResponse
 IdTCPConnection    563   +2 TIdTCPConnection.GetResponse
 IdTCPConnection    583   +4 TIdTCPConnection.SendCmd
 IdTCPConnection    696   +4 TIdTCPConnection.SendCmd
 IdSMTP             377   +2 TIdSMTP.DisconnectNotifyPeer
 IdTCPConnection    517   +5 TIdTCPConnection.Disconnect
 IdSMTP             476   +2 TIdSMTP.Disconnect
 IdTCPConnection    828   +2 TIdTCPConnection.Disconnect
 Email              130  +11 TEmail.Destroy
 System            9806   +1 TObject.Free
 EnviarEmail        322  +38 TFormEnviarEmail.Enviar
 System           12106  +38 @HandleFinally
                             RtlUnwind
 System           11589  +83 @HandleAnyException
                             KiUserExceptionDispatcher
                             RtlAppendUnicodeToString
 IdMessageClient    873   +4 EncodeAttachment
 IdMessageClient   1213 +252 TIdMessageClient.SendBody
 IdMessageClient   1244 +283 TIdMessageClient.SendBody
 IdMessageClient   1269  +12 TIdMessageClient.SendMsg
 IdSMTPBase         251   +6 TIdSMTPBase.SendNoPipelining
 IdSMTPBase         436   +4 TIdSMTPBase.InternalSend
 IdSMTPBase         457   +1 TIdSMTPBase.Send
 IdSMTP             415   +6 TIdSMTP.Send
 IdSMTPBase         449   +6 TIdSMTPBase.Send

Any clues about what is causing it and how can I solve the problem?

Thanks.

A: 

Have you confirmed you can send the same mail with a bona fide mail client, preferably a simple and portable one which doesn't integrate into the bowels of the system, like Mozilla Thunderbird or Opera's included mail client? There could be an antivirus / antispam / antiwhatever system interfering there - many of those transparently intercept outgoing 25/TCP and do stuff to the data.

Mihai Limbășan
A: 

If the encoding is not the reason, but a read time out, you could increase it using the ReadTimeOut property:

IdSMTP1.ReadTimeOut := 20000;

mjustin
Changing the ReadTimeOut to 20000 resulted in an EIdReadTimeOut exception, what does it mean?
Fabio Gomes
Indy reports the time out by raising a EIdReadTimeOut exception. So this tells you that there is actually only a server side problem: server did not send any data for 20 seconds
mjustin
A: 

Problem solved.

I'm parsing an HTML file to load the images and attach them in the email, but in windows XP the path is:

C:\Documents And Settings\User\Desktop\....

And in the html file this path was

C:\Documents%20And%20Settings\User\Desktop\....

So a File not Found exception was being raised internally and stopping the process, till timeout, and Indy wasn't raising it.

After attaching a remote debugger in the process running on the Windows XP machine I got the exception in the first try.

I don't think its correct for Indy to "engulf" the exception, but that's another history.

Fabio Gomes
Indy will wait for the system-specific timeout period, which is quite long on a Windows system. I have been bitten by this one too already.
mjustin