Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cannot send email (Indy) - Getting Socket Error # 10060

Status
Not open for further replies.

BebopSong

Programmer
Apr 3, 2008
10
GB
Hi,

I am trying to send an email using the indy components and I seem to be getting the error 'Socket Error # 10060 Connection timed out'. I am just trying to send a test email to myself. and I am using smtp.googlemail.co.uk as the host name with my username and password. I thought the firewall might be getting in the way so i tried disabling it and still the same thing happens. Any ideas?
Code:
procedure TfrmMaintenance.btnTestClick(Sender: TObject);
var Prob: boolean;
begin
    if chkInternet.Checked then exit;
    prob := false;
    if tblSecurity.state in [dsEdit,dsInsert] then tblSecurity.post;
    try
        EmailMess.ClearBody;
        EmailMess.Body.Add('Test email');
        EmailMess.Subject := 'Email Test';
        EmailMess.Recipients.EMailAddresses := tblSecurity.FieldByName('SenderEmail').AsString;
        if tblSecurity.FieldByName('AuthServer').AsBoolean then
            EmailSMTP.AuthenticationType := atLogin
        else
            EmailSMTP.AuthenticationType := atNone;
        EmailMess.From.Address := tblSecurity.FieldByName('SenderEmail').AsString;
        EmailMess.Sender.Address := tblSecurity.FieldByName('SenderEmail').AsString;
        EmailSMTP.host := tblSecurity.FieldByName('HostServer').AsString;
        EmailSMTP.UserName := tblSecurity.FieldByName('UserName').AsString;
        EmailSMTP.Password := tblSecurity.FieldByName('UserPassword').AsString;
        if EmailSMTP.Connected then
            EmailSMTP.Disconnect;
        EmailSMTP.Connect;
        EmailSMTP.Send(EmailMess);
        EmailSMTP.Disconnect;
    except
        Application.HandleException(Self);
        prob := true;
    end;
end;
When stepping-through I notice that the atLogin authenticationType is executed and that the code breaks on the EmailSMTP.Connect; part.

Any help would be greatly appreciated.

Regards

BebopSong
 
are you allowed to connect to this server? as in, does the server exist, and has it been made publicly available for people to send mail with?
 
Yes I am allowed to connect. I have set up Outlook to receive any of my emails and also to send them and that works fine.

I am not sure about the port number on the idSMTP component. Is it always going to be 25 or will that change depending on if it is a SSL connection? I ask because when setting up Gmail in Outlook it says for [bold]Outgoing Mail (SMTP)[/bold, tick the box next to [bold]This server requires a secure connection (SSL)[/bold]. Then it says enter 465. for incoming it says the same but with 993?

Regards
BebopSong
 
Outgoing (SMTP) and incoming (POP) port numbers are always different. Typically 25 & 110 respectively, by default.

Secured mail servers typically use 465 & 993, as you noted.

Roo
Delphi Rules!
 
I have tried using the 465 port number and the program just freezes. Do I have to do anything with the POP port number?
 
>I have set up Outlook to receive any of my emails and also to send them and that works fine.

That doesn't mean anything. The server could be set up to block unknown programs to keep it from being used as a spam relay. That's what you have to find out.
 
Thanks, I for the help. I have found out that Mozilla Firefox blocks all the default SMTP ports: 25, 465 and 587. Mozilla recommend this,

"If your product or web site uses a port which is blocked by Mozilla's default port blocking rules, you can either change the port of your service to a unblocked value {recommended if possible) or ask your Mozilla users to enable the port. For details on which ports are blocked and how to override the blocking see below."

How do I go about changing the port that I use. I thought I had to use 25, 465 or 587? Also does IE7 block the ports in the same way?
 
Mozilla Firefox is not a firewall - therefore, unless what you're writing is an extension or plugin for Firefox, it's policies are unrelated to your problem.

Maybe the Windows Firewall is blocking you?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top