使用SMTP发送电子邮件与Delphi连接超时错误? [英] Connection timed out error when using SMTP to send emails with Delphi?

查看:955
本文介绍了使用SMTP发送电子邮件与Delphi连接超时错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用delphi 2010发送电子邮件地址,例如(修复电子邮件,密码丢失或任何html /纯文本电子邮件。

how to send an email address with delphi 2010 such as ( verefication email, password lost, or any html/plain text emails.

我尝试使用以下代码但是,当尝试发送邮件时,我会收到 EIdSocket Eroor消息Socket Error#10060 Connection Timed Out

i tried with the following code but i get EIdSocket Eroor with message 'Socket Error #10060 Connection Timed Out' when trying to send the mail.

procedure TForm5.btnSendMailClick(Sender: TObject);
begin

//setup SMTP
smtppass := ed_IdVerification.Text;
SMTP.Host := 'smtp.google.com';   // Controle a distance
SMTP.Port := 465;
smtp.Username := 'hetallica69@gmail.com';
smtp.Password := QuotedStr(smtppass);


//setup mail message

MailMessage.From.Address := 'hetallica69@gmail.com';
MailMessage.Recipients.EMailAddresses := '_rafik@live.fr';

MailMessage.Subject := 'Confirm your account';
MailMessage.Body.Text := 'Text goes here';

//send mail
try
 try
   if not smtp.Connected then SMTP.Connect() ;
   SMTP.Send(MailMessage) ;
 except on E:Exception do
   ShowMessage(E.Message);
 end;
   finally
     if SMTP.Connected then SMTP.Disconnect;
   end;
end;


推荐答案

您收到的错误意味着连接是在此行失败: SMTP.Connect()

The error that you are receiving means that the connection is failing on this line: SMTP.Connect().

通常,这意味着端口错误,服务器没有连接,或者您没有连接。

Usually, it means the port is wrong, the server is not up, or you don't have connectivity.

在这种情况下,您没有连接,很可能是因为您的ISP阻止连接到该远程端口

In this case, you don't have connectivity, most likely because your ISP is blocking connection to that remote port.

尝试从托管的网络服务器发送电子邮件。

Try sending the email from your hosted web server.

即使你可以连接,你的代码也赢了按照原样工作。 Google SMTP服务器端口465需要安全(SSL)连接。你仍然需要实现。看看:我如何使用Gmail的SMTP和Indy 10发送电子邮件?

Even if you could connect, your code won't work as is. Port 465 on Google's SMTP server requires a secure (SSL) connection. You'll still need to implement that. Take a look at: How do I send e-mail using Gmail's SMTP and Indy 10?

这篇关于使用SMTP发送电子邮件与Delphi连接超时错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆