delphi – Indy 10 – IdSMTP.Send()在从GMail帐户发送邮件时挂起

前端之家收集整理的这篇文章主要介绍了delphi – Indy 10 – IdSMTP.Send()在从GMail帐户发送邮件时挂起前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在尝试使用这些设置使用gmail帐户(Delphi 7,Indy 10)发送电子邮件

TIdSmtp:

Port = 587;
UseTLS := utUseExplicitTLS;

TIdSSLIOHandlerSocketOpenSSL:

SSLOptions.Method := sslvTLSv1;

一切似乎都设置好了.我收到了这个回复

Resolving hostname smtp.gmail.com.
Connecting to 74.125.77.109.
SSL status: "before/connect initialization"
SSL status: "before/connect initialization"
SSL status: "SSLv3 write client hello A"
SSL status: "SSLv3 read server hello A"
SSL status: "SSLv3 read server certificate A"
SSL status: "SSLv3 read server done A"
SSL status: "SSLv3 write client key exchange A"
SSL status: "SSLv3 write change cipher spec A"
SSL status: "SSLv3 write finished A"
SSL status: "SSLv3 flush data"
SSL status: "SSLv3 read finished A"
SSL status: "SSL negotiation finished successfully"
SSL status: "SSL negotiation finished successfully"
Cipher: name = RC4-MD5; description = RC4-MD5                 SSLv3 Kx=RSA      Au=RSA  Enc=RC4(128)  Mac=MD5 
; bits = 128; version = TLSv1/SSLv3;

然后它挂起并没有完成.电子邮件未发送.可能是什么问题?

解决方法

是的,我已经看到了indy10和tls(通常是gmail)的很多问题.

首先确保你有最新的ssl库from here

我已经看到间歇性的失速和错误已经在indy的最新版本中得到解决(即非稳定释放).见http://www.indyproject.org/sockets/download/svn.DE.aspx

对于gmail,我通常在端口465上使用implicityTLS ..

idSmtp := TIdSMTP.Create(nil);
  try
    idSmtp.IOHandler := nil;
    idSmtp.ManagedioHandler := true;

    // try to use SSL
    try
      TIdSSLContext.Create.Free;
      idSmtp.IOHandler := TIdSSLIOHandlerSocketOpenSSL.Create(idSmtp);
      if (smtpSettings.port = 465) then
        idSmtp.UseTLS := utUseImplicitTLS
      else
        idSmtp.UseTLS := utUseExplicitTLS;
    except
      idSmtp.IOHandler.Free;
      idSmtp.IOHandler := nil;
    end;

    if (idSmtp.IOHandler = nil) then
    begin
      idSmtp.IOHandler := TIdioHandler.MakeDefaultIOHandler(idSmtp);
      idSmtp.UseTLS := utNoTLSSupport;
    end;

    // send message,etc

  finally
    idSmtp.Free;
  end;

猜你在找的Delphi相关文章