Re: Smtp authentification problem

Giganews Newsgroups
Subject: Re: Smtp authentification problem
Posted by:  Remy Lebeau \(Indy Team\) (no.spam@no.spam.com)
Date: Thu, 23 Nov 2006

"Sylvain" <sylvain.amy…@sftsa.com> wrote in message
news:1FF526209410E340sylvain.amy…@sftsa.com...

>    xIoHandler := TIDSSLIOHandlerSocketBase.Create;

You are creating the wrong class.  TIdSSLIOHandlerSocketBase is an abstract
base class that does not actually implement SSL.  You need to use
TIdSSLIOHandlerSocketOpenSSL instead.

>    Smtp.UseTLS    := utUseRequireTLS;
>    SMTP.Port      := 25;

Port 25 is SMTP's unsecure port.  If you use port 25, then you should set
UseTLS to utUseExplicitTLS instead.  That will cause TIdSMTP to send a
STARTTLS command to the server when it is ready to initialize a secure
tunnel.

Otherwise, leave UseTLS set to utUseImplicitTLS and then use port 465
instead, with is SMTP's secure port.

>    MailMessage.Recipients.EMailAddresses := ledTo.Text + ',' +
> ledCC.Text;

TIdMessage has a separate CCList propety for CC addresses:

    MailMessage.Recipients.EMailAddresses := ledTo.Text;
    MailMessage.CCList.EMailAddresses := ledCC.Text;

>    MailMessage.Body.Assign(Html);

You need to set the ContentType property in order for the HTML to appear
properly in the reader:

    MailMessage.ContentType := 'text/html';

>    //send mail

You have you try..finally and try..except blocks reversed:

    try
        SMTP.Connect;
        try
            SMTP.Send(MailMessage);
        finally
            SMTP.Disconnect;
        end;
    except
        on E:Exception do
            StatusMemo.Lines.Insert(0, 'ERROR: ' + E.Message);
    end;

Gambit

Replies

In response to

Smtp authentification problem posted by Sylvain on Thu, 23 Nov 2006