3
votes

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.

1
So the server you're communicating with is an exchange server? So the problem is making an SSL connection to Exchange? Does it work when you try it with Mozilla Thunderbird Email client? If it doesn't work with that, why are you trying to write code for something that might not be configured to work properly on the server end?Warren P
Hey Warren P. Thanks for your reply. The server is not an exchange server. My assumption is that if I can send mails from Microsoft office 2007, I should be able to do the same with my delphi code. I am hoping that I just missed something in my code or component atributes.Overklog
Well then, try it in some OTHER email program than Exchange, and figure out what authentication settings you need there, and that might tell you what to do. TLS etc.Warren P

1 Answers

3
votes

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