how to send an email address with delphi 2010 such as ( verefication email, password lost, or any html/plain text emails.
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 := '[email protected]';
smtp.Password := QuotedStr(smtppass);
//setup mail message
MailMessage.From.Address := '[email protected]';
MailMessage.Recipients.EMailAddresses := '[email protected]';
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;
If you get a 'Connection Timed out' error when sending email via our SMTP relay, it means that you are using an smtp port that is blocked. By default, we recommend using port 25 when sending emails via our SMTP relay. However, some ISPs may block port 25.
The error indicates that the server didn't respond to the client and the client program gave up (timed out). The following are common causes for this error: The security group or network ACL doesn't allow access. There is a firewall on the instance's operating system.
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.
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.
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?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With