Catching EIdSMTPReplyError exception

Giganews Newsgroups
Subject: Catching EIdSMTPReplyError exception
Posted by:  ClĂ©ment_Doss
Date: Sat, 17 Mar 2012

Hi,

I'm using DXE2 with Indy 10 that came with it.

I added the ##Newcode line hoping to get some more precise information
The fact is that when I run the application in debug mode + delphi IDE I get a
nice error explaining what's happening,i.e :

"raised exception class EIdSMTPReplyError with message 'Este dominio nao esta
autorizado para enviar emails sem autenticacao, para enviar emails basta
autenticar sua senha clicando no botao eao Enviar/receber de seu programa de
email. Opcionalmente e possivel eliminar este erro alterando a porta do SMTP de
25 para 2525 e marcando a opcao meu Servidor Requer Autenticacao"

But I only manage to catch an 'Authorization failed (5.'.

How can I get the detailed error?

TIA,
Clément

----

var
  eMsg : TidMessage;
begin
  FidTLSHandler := nil;
  eMsg := nil;
  try
    AssignSMTPproperties( aHost, aPort, aUserName, auserPassword, aDomainName,
aConnectionSecurity );
    eMsg := CreateMessage( aFromName,
                            aFromAddress,
                            aSubject,
                            aBody,
                            aToList,
                            aCCList,
                            aBCCList,
                            aOrganizationName,
                            aRetRecName,
                            aRetRecAddress,
                            aAttachmentFileList);
    try
        FSMTP.Connect(aHost, aPort);
        FSMTP.Send(eMsg);
    except
        on e:exception do begin
          aErrMsg := e.Message;
          // ## NewCode
          if FSMTP.LastCmdResult.Code<>'' then
              aErrMsg := FSMTP.LastCmdResult.Text.Text +#13#10+'--'+#13#10+ aErrMsg;
        end;
    end;
  finally
      FSMTP.Disconnect;
      eMsg.Free;
      Result := aErrMsg = '';
  end;

Replies