Re: Creating SASLMechanisms at runtime?

Giganews Newsgroups
Subject: Re: Creating SASLMechanisms at runtime?
Posted by:  Remy Lebeau (TeamB) (no.spam@no.spam.com)
Date: Sat, 27 Nov 2004

"Pete Royston" <pete…@royston.com> wrote in message
news:E7AFB897C3B5E240pete…@royston.com...

>  I am creating the TidSMTP at runtime, and want to use SASL,
> but the only example I can find says "drop the following components
> on the form".  I've tried creating them by hand, but I am getting AVs
> when I run.

That is because you are not using them properly.

>  So I upgrade to 9.0 and I can't send mail at all, the exception
> raised was a string of garbage characters.

Please elaborate.

>  So I upgraded to the latest 10.0 version, and things are working
> better. It will authenticate (atDefault) but then it will not allow me
> to send any email because it says "not local host xyz.com not a
> gateway".

Please show your actual code.

>  So I am hoping that switching to SASL will solve the problem.
> But since I'm creating everything dynamicaly, I'm having trouble
> getting that setup.

What is so hard to understand about the SASLMechanisms?  TIdSMTP has a
SASLMechanisms property that is a collection of supported SASL entries.
Simply add a new entry it to, and then assign the item's SASL property to
the desired SASL algorithm that you want to use.

> I've tried various cominations, like:

That code is completely wrong.  You do not create the TIdSASLEntries
component yourself at all.  TIdSMTP has its own instance that it owns which
you should be using instead.  As such, your code should look more like the
following instead:

    CRAMMD5 := TIdSASLCRAMMD5.Create(IdSMTP);
    CRAMMD5.UserPassProvider := TIdUserPassProvider.Create(CRAMMD5);
    CRAMMD5.UserPassProvider.Password :=  'thepw';
    CRAMMD5.UserPassProvider.Username := 'theid';
    IdSMTP.SASLMechanisms.Add.SASL := CRAMMD5;

Gambit

Replies

In response to

Creating SASLMechanisms at runtime? posted by Pete Royston on Sat, 27 Nov 2004