Problems when changing the port number of TIdSMTP

Giganews Newsgroups
Subject: Problems when changing the port number of TIdSMTP
Posted by:  HDumas (du…@hotmail.com)
Date: Thu, 10 Jan 2008

Hello,

I have Delphi 7 and the Indy components that come with it. I need to send an
email, using our exchange server.
Here is the code that I am having trouble with.

  wkSMTP := TIdSMTP.Create(nil);
  wkSMTP.Port := 5555;
  wkSMTP.QuickSend(iniHostCourriel, p_Objet, p_Destinataires, p_Expediteur,
p_Text);
  FreeAndNil(wkSMTP);

Although I changed the port number, it stills try to send through port 25...
To make sure that I could connect to this other port, I tried the following
code.(I put a breakpoint on the Connect line so that I could have time to
verify on our exchange server that I am connected)

  wkSMTP := TIdSMTP.Create(nil);
  wkSMTP.Port := 5555;
  wkSMTP.Connect();
  FreeAndNil(wkSMTP);

Then I create a TIDmessage and when I try to do the send, it gives me an
EIdProtocolReplyError with a message 5.5.4 Invalid Address.  Here is the
code.
  wkMessage := TIdMessage.Create(nil)
  wkMessage.Clear;
  wkMessage.From.Text := p_Expediteur;
  wkMessage.Recipients.Add.Text := p_Destinataires;
  wkMessage.Subject := p_Objet;
  wkMessage.Body.Add(p_text);
  wkSMTP := TIdSMTP.Create(nil);
  wkSMTP.Port := 5555;
  wkSMTP.Connect();
  try
    wkSMTP.Send(wkMessage);
  finally
    wkSMTP.Disconnect;
  end;

When I go to see the log on the exchange server, I has a line to show that
there has been a connection to the port 5555... there are 3 lines
EHLO-250
MAIL-250
QUIT-240
But if not specifiying the port 5555 and keeping it on the port 25...
everything works fine and in the log, it shows this
EHLO-250
MAIL-250
RECP-250
DATA-250
QUIT-240

Can anybody tell me why I cannot send an email using the port 5555 of the
exchange server??  Thank you for any help or hints you can give me.

H. Dumas

Replies