无法使用 Indy 发送电子邮件(通过 GMail)。协议版本不匹配
Cannot send email (via GMail) with Indy. Protocol version mismatch
我想通过 GMail 服务器发送电子邮件。
TRY
SMTP.Connect; // <---- This is TIdSMTP
EXCEPT
Log.AddError('Cannot connect to the email server.');
END;
if SMTP.Connected then
TRY
SMTP.Send(MailMessage);
EXCEPT
on E:Exception DO
begin
Log.AddError('Connected to server but could not send email!');
Log.AddError(E.Message);
end;
END;
if SMTP.Connected
then SMTP.Disconnect;
这段代码在 2014 年与 Delphi XE 一起工作。
程序连接到服务器正常,但最后显示 "SSL is not available on this server":
Resolving hostname smtp.Gmail.com.
Connecting to 74.125.xxx.xxx
Connected.
Connected to SMTP server...
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 hello A"
Disconnected.
Connected to server but could not send email!
SSL is not available on this server.
我有最新版本的 OpenSSL(今天下载)和 Delphi XE7。
WireShark 说:
Alert (Level: Fatal, Description: Protocol version)
为什么我无法发送电子邮件?
我已经尝试了所有:无 TSL、隐式、显式、startTSL...
解决方案: sslvTLSv1 必须包含在 SSLIOHandler.SSLVersions
属性 中。
我想通过 GMail 服务器发送电子邮件。
TRY
SMTP.Connect; // <---- This is TIdSMTP
EXCEPT
Log.AddError('Cannot connect to the email server.');
END;
if SMTP.Connected then
TRY
SMTP.Send(MailMessage);
EXCEPT
on E:Exception DO
begin
Log.AddError('Connected to server but could not send email!');
Log.AddError(E.Message);
end;
END;
if SMTP.Connected
then SMTP.Disconnect;
这段代码在 2014 年与 Delphi XE 一起工作。
程序连接到服务器正常,但最后显示 "SSL is not available on this server":
Resolving hostname smtp.Gmail.com.
Connecting to 74.125.xxx.xxx
Connected.
Connected to SMTP server...
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 hello A"
Disconnected.
Connected to server but could not send email!
SSL is not available on this server.
我有最新版本的 OpenSSL(今天下载)和 Delphi XE7。
WireShark 说:
Alert (Level: Fatal, Description: Protocol version)
为什么我无法发送电子邮件?
我已经尝试了所有:无 TSL、隐式、显式、startTSL...
解决方案: sslvTLSv1 必须包含在 SSLIOHandler.SSLVersions
属性 中。