SMTP + SSL connection

Giganews Newsgroups
Subject: SMTP + SSL connection
Posted by:  Isaac (cyberm…@ms18.url.com.tw)
Date: Sat, 12 Mar 2005

Hi,

  I use Indy 10 (10.0.52) and TIdSMTP component to implement a mail
client. So far it works fine when sending mails to normal SMTP servers.

  Now I have some Gmail accounts which need to use SSL connection,
so I create a TIdSSLIOHandlerSocketOpenSSL componen and attach it
to the TIdSMTP component. But the deliverery is always failed.
(timeout occurred, I thought the problem was during authentication phrase)

  The code is like the following:

----------------------------------------------------------------------------

  FSSLIOHandler = new TIdSSLIOHandlerSocketOpenSSL(NULL);
  FSSLIOHandler->SSLOptions->Mode = sslmClient;
  FSMTP->IOHandler = FSSLIOHandler;

  FUserPassProvider = new TIdUserPassProvider(NULL);
  FUserPassProvider->Username = "x…@gmail.com";
  FUserPassProvider->Password = "xxx";

  TIdSASLListEntry *SASLEntry = FSMTP->SASLMechanisms->Add();
  SASLEntry->SASL = new TIdSASLLogin(NULL);
  SASLEntry->SASL->UserPassProvider = FUserPassProvider;

  FSMTP->Host = "smtp.gmail.com";
  FSMTP->Port = 465;
  FSMTP->Send(Message);
----------------------------------------------------------------------------

Thanks.

Best regards

Replies