尝试 TidSMTP.Connect 时连接超时
尝试连接 Gmail smtp 服务器失败。
它只是挂在那里大约 20 秒,然后抛出错误“Socket Error #10060 Connection timed out”。
我什至尝试从这个 post,但这也不起作用。
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;
idSMTPGMail.UserName := 'username';
idSMTPGMail.Password := 'Password';
idSMTPGMail.Connect;
idSMTPGMail.Send(email);
idSMTPGMail.Disconnect;
email.Free;
idSSLGMail.Free;
idSMTPGMail.Free;
Beep;
end;
有谁有什么想法我该如何解决这个问题?
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;
idSMTPGMail.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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否处于防火墙后面?
Are you behind a firewall, by any chance?