Newsgroups : Borland : borland.public.delphi.internet.winsock : 2006 Mar : Re: indy 10... a piece of crap

www.cryer.info
Managed Newsgroup Archive

Re: indy 10... a piece of crap

Subject:Re: indy 10... a piece of crap
Posted by:"Remy Lebeau (TeamB)" (no.spam@no.spam.com)
Date:Tue, 28 Mar 2006 18:31:54

"twistedvoid" <postmaster@twistedvoid.com> wrote in message
news:4429b3fe$1@newsgroups.borland.com...

> I had the program written in Indy set to the same port as my netscape
> email client, 465.  The e-mail client sent SMTP fine through that port,
> the program didn't.  I set the program to port 587 and it started
> working.  I still have no idea why netscape email has no problem
> with port 465 but the program written with Indy does.

Port 465 is for SSMTP, aka SMTP with SSL.  You have to attach Indy's SSL
IOHandler class to the TIdSMTP in order for it to handle SSL connections.
Now your earlier hanging makes complete sense, since Connect() is trying to
read SMTP data over an encrypted connection that it does not understand how
to manage by default.

Also, just for reference, the standard SMTP port is 25, not 587.  587 is for
the Submission protocol, which has nothing to do with SMTP.

> I tried your extraheaders and it added the header just fine,
> thanks for that.  But, it put the messagepart in the wrong
> place.

Indy 10 writes the message parts in the order that they appear in the
collection.  It is your own responsibility to make sure the parts are in the
order that you need them to be in, and that their ParentParts properties are
set correcty.

> In order for the 'inline' attachment to be displayed properly it has
> to come after all other messageparts, including attachments.

Then simply add your 'inline' part at the end of the MessageParts
collection.

> When Indy assembles the message it lumps all text messageparts together.

Indy 10 writes them in the order they appear in the collection.

> For example:  Create a textpart then add a file attachment.  Then add
> in my 'inline' attachment as TIDtext, it gets placed between the text
> part and the file attachment.

That may have been the case in Ind 9 , but that is not the case in Indy 10.

> I need this
>
> Textpart
> HTMLpart
> FileAttachment
> 'Inline' part

For Indy 10, you can set tht up using the following:

    IdMessage.ClearBody;
    IdMessage.ContentType := 'multipart/mixed';

    TIdText.Create(IdMessage.MessageParts, nil).ContentType :=
'multipart/alternative';

    with TIdText.Create(IdMessage.MessageParts, nil) do
    begin
        ContextType := 'text/plain';
        Body.Text := 'whatever';
        ParentPart := 0;
    end;

    with TIdText.Create(IdMessage.MessageParts, nil) do
    begin
        ContextType := 'text/html';
        Body.Text := '<html>whatever</html>';
        ParentPart := 0;
    end;

    with TIdAttachmentFile(IdMessage.MessageParts, 'filename.ext') do
    begin
        ContentType := GetMimeTypeFromFile('filename.ext');
        ParentPart := -1;
    end;

    with TIdText.Create(IdMessage.MessageParts, nil) do
    begin
        ContextType := 'text/plain';
        Body.Text := 'whatever';
        ExtraHeaders.Values['Content-Disposition'] := 'inline';
        ParentPart := -1;
    end;

> Even if I do write my own class for this, will the mesageparts be added to
the message in the order I create them

In Indy 10, yes.

> Oh, I understood, I simply couldn't understand why I was
> getting a connect message where it was obviously connecting to
> the port but then, not doing anything.  Once I got the port number
> set properly, it started displaying traffic.  It's also going to be very
> confusing for my customers should they set the port improperly as
> Indy with just display 'connection closed gracefully.'  Not a very
> helpful error message.

There is nothing you or Indy can do about that.  If there is a server
listening on that port, then Indy will connect to it.  If the data that is
exchanged on that socket is not what Indy expects, it has no way to detect
that ahead of time.

However, all is not lost.  TIdSMTP in Indy 10 has built-in support for port
SSMTP on port 587.  All you have to do is attach the SSL IOHandler to the
TIdSMTP before calling Connect(), and then set the UseTLS property to a
value other than utNoTLSSupport, ie:

utUseImplicitTLS uses SSL unconditionally from the moment the socket is
connected (which appears to be what your server is expecting in this
situation).

utUseRequireTLS and utUseExplicitTLS allow TIdSMTP to query the server for
its capabilities after connecting and then enable SSL dynamically only if
the server allows it.


Gambit

Replies:

none

In response to:

www.cryer.info
Managed Newsgroup Archive