Overklog
Overklog

Reputation: 119

Delphi Indy 10 Smtp Error "Unable to authenticate at present"

I am using this piece of code to mail a test message from delphi indy. I have a TidSMTP,TIdMessage and IdSSLIOHandlerSocketOpenSSL;

In the belowe code if i set it up to use gmail with ssl it works fine, but as soon as i replace my the server details with my cpanel mail server detials it does not work error:

" unable to authenticate at present".

I used same details I would use to setup my account in outlook 2007. Here is the code

IdSSLIOHandlerSocketOpenSSL details.

method := sslvsslv3
mode := sslmUnassigned

//rest default values

procedure Tfrmnotification.btnSendClick(Sender: TObject);
var
  IdMsg : TIdMessage;
begin

begin
  IdMsg := TIdMessage.Create(nil);
  try
    with TIdSMTP.Create(nil) do
    try
     // UserName := '[email protected]';
     // Password := 'pass';
     // Host := 'smtp.gmail.com';
     // IOHandler := IdSSLIOHandlerSocketOpenSSL;
     // Port := 587;
      UserName := '[email protected]';
      Password := 'password';
      Host := 'outgoing server detials';// same as outlooks
      IOHandler := IdSSLIOHandlerSocketOpenSSL;
      Port := 465;// this is correct port
      UseTLS:=  utUseExplicitTLS;


      IdMsg.Body.Add('test');
      IdMsg.Recipients.emailAddresses := '[email protected]';
      IdMsg.Subject := 'test';
      IdMsg.From.Address := '[email protected]';
      IdMsg.From.Name := 'john';


      Connect;
      Send(IdMsg);
      Disconnect;
    finally
      Free;
    end;
  finally
    IdMsg.free;
  end;
  showmessage('done');
end;

Any help would be appricated.

Upvotes: 3

Views: 3676

Answers (1)

Henrick Hellström
Henrick Hellström

Reputation: 2666

Port 465 is used for SMTP over implicit SSL. You have set UseTLS to utUseExplicitTLS. The correct value should (most likely) be utUseImplicitTLS.

Upvotes: 3

Related Questions