Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > General

Lost Password?

Reply
 
Thread Tools Display Modes
  #1  
Old 06-22-2012, 04:24 PM
stoker stoker is offline
Junior Member
 
Join Date: Jun 2012
Posts: 13
Default send email with Indy components problem

Hi all, I try to send an email, but I have a problem, however, I found this code on the web:

Code:
procedure SendSimpleMail;
var
  IdSMTP: TIdSMTP;
  IdMessage: TIdMessage;
  IdEmailAddressItem: TIdEmailAddressItem;
begin
  IdSMTP := TIdSMTP.Create(nil);
  try
    IdSMTP.Host := 'smtp.gmail.com';
    IdSMTP.Port := 25;
    IdSMTP.AuthType := atDefault;
    IdSMTP.Username := 'username@gmail.com';
    IdSMTP.Password := 'password';
    IdSMTP.Connect;
    if IdSMTP.Authenticate then
    begin
      IdMessage := TIdMessage.Create(nil);
      try
        IdMessage.From.Name := 'User Name';
        IdMessage.From.Address := 'username@gmail.com';
        IdMessage.Subject := 'E-mail subject';
        IdMessage.Body.Add('E-mail body.');

        IdSMTP.Send(IdMessage);
      finally
        IdMessage.Free;
      end;
    end;
    IdSMTP.Disconnect;
  finally
    IdSMTP.Free;
  end;
end;
but when try to send email, the program give me an error:

Code:
Socket error # 10060
Connection timed out
Why?
Thanks!
Reply With Quote
  #2  
Old 06-22-2012, 05:57 PM
Ouiji Ouiji is offline
Senior Member
 
Join Date: Nov 2001
Location: US of A
Posts: 478
Send a message via AIM to Ouiji
Default

You may want to have a look at this page, as gmail requires a little different configuration than you are working with.

http://support.google.com/mail/bin/a...n&answer=13287
__________________
"not quite smart enough to be dumb"
Extended Stats No Longer Available Due To Changes To The Forum.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT. The time now is 02:40 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2013, vBulletin Solutions, Inc.