Hangs - from Indy, To Gmail with SMTP

Giganews Newsgroups
Subject: Hangs - from Indy, To Gmail with SMTP
Posted by:  Allan Fernandes (allan_fernand…@yahoo.co.uk)
Date: Fri, 5 Aug 2011

Hi,

Why does this hang ?
I have Googled, asked on Experts-Exchange etc.etc.
I use Delphi 2007 Updated with indy10.0.52 on Win XP sp3

Regards
Allan

procedure TForm1.Button1Click(Sender: TObject);
begin
{ DFM contents:
  object IdSMTP1: TIdSMTP
    OnStatus = IdSMTP1Status
    IOHandler = IdSSLIOHandlerSocketOpenSSL1
    SASLMechanisms = <>
  end}

  IdSMTP1.Host:='smtp.gmail.com' ;
  IdSMTP1.Password := 'xxxx';
  IdSMTP1.Port := 587;
  IdSMTP1.Username := 'ab…@gmail.com';
  IdSMTP1.UseTLS:= utUseExplicitTLS ;

{ DFM contents:
  object IdSSLIOHandlerSocketOpenSSL1: TIdSSLIOHandlerSocketOpenSSL
    OnStatus = IdSSLIOHandlerSocketOpenSSL1Status
    MaxLineAction = maException
    DefaultPort = 0
    SSLOptions.Method = sslvTLSv1
    SSLOptions.Mode = sslmUnassigned
    SSLOptions.VerifyMode = []
    SSLOptions.VerifyDepth = 0
  end}

  IdSSLIOHandlerSocketOpenSSL1.Destination := 'smtp.gmail.com:587' ;
  IdSSLIOHandlerSocketOpenSSL1.Host := 'smtp.gmail.com' ;
  IdSSLIOHandlerSocketOpenSSL1.Port := 587 ;

  IdMessage1.From.Address := 'ab…@gmail.com';
  IdMessage1.Recipients.EMailAddresses := 'x…@uuu.com'  ;

  IdMessage1.Subject := 'The Subject';
  IdMessage1.Body.Text := Memo1.Lines.Text;

  IdSMTP1.Connect();
  IdSMTP1.Send(IdMessage1);
  IdSMTP1.Disconnect;
end;

procedure TForm1.IdSMTP1Status(ASender: TObject; const AStatus: TIdStatus;
const AStatusText: string);
begin
    Memo1.Lines.Add(AStatusText);
{Output :
Connected
}
end;

procedure TForm1.IdSSLIOHandlerSocketOpenSSL1Status(ASender: TObject;  const
AStatus: TIdStatus; const AStatusText: string);
begin
    Memo2.Lines.Add(AStatusText);
{Output :
Resolving hostname
smtp.gmail.com
Connecting to 74.125.127.109
}
end;

Replies