开发者

Connection timed out when trying to TidSMTP.Connect

Trying to connect with Gmail smtp server fails.

It just hangs there ~20 seconds and then throws error "Socket Error #10060 Connection timed out".

I've tried even copy and paste from this post, but that doesn't work also.

procedure TForm1.btn1Click(Sender: TObject);
var
  email      : TIdMessage;
  idSMTPGMail: TIdSMTP;
  idSSLGMail : TIdSSLIOHandlerSocketOpenSSL;
begin
  idSSLGMail                   := TIdSSLIOHandlerSocketOpenSSL.Create(nil);
  idSSLGMail.SSLOptions.Method := sslvTLSv1;
  idSSLGMail.SSLOptions.Mode   := sslmUnassigned;

  idSMTPGMail                  := TIdSMTP.Create(nil);
  idSMTPGMail.IOHandler        := idSSLGMail;
  idSMTPGMail.UseTLS           := utUseExplicitTLS;

  email                           := TIdMessage.Create(nil);
  email.From.Address              := 'from';
  email.Recipients.EMailAddresses := 'recipient';
  email.Subject                   := 'test subject';
  email.Body.Text                 := 'test body';

  idSMTPGMail.Host     := 'smtp.gmail.com';
  idSMTPGMail.Port     := 587;
  idSM开发者_运维问答TPGMail.UserName := 'username';
  idSMTPGMail.Password := 'Password';

  idSMTPGMail.Connect;
  idSMTPGMail.Send(email);
  idSMTPGMail.Disconnect;

  email.Free;
  idSSLGMail.Free;
  idSMTPGMail.Free;
  Beep;

end;

Has anyone any ideas how could i solve that problem?


Are you behind a firewall, by any chance?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜