Watch, Follow, &
Connect with Us

Please visit our new home
community.embarcadero.com.


Welcome, Guest
Guest Settings
Help

Thread: sending email [exchange] using indy - failed



Permlink Replies: 0
Yaniv Haliwa

Posts: 8
Registered: 9/16/16
sending email [exchange] using indy - failed
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 15, 2017 9:16 AM
hey guys, im new here in the forum but im using delphi for a while . i need to do procedure that sent email from my work email exchange to another emails. i saw some example bout it, but all thew options was failed. im attacthing the code i really really appriciate if u can tell me whats is wrong.
the error im getting is "socket erorr 10054 connection reset by peer"

here is the procedure
procedure SendEmail(username, password, totarget, subject, body: string);
var
  DATA: TIdMessage;
  SMTP: TIdSMTP;
  SSL: TIdSSLIOHandlerSocketOpenSSL;
begin
  SMTP := TIdSMTP.Create(nil);
  DATA := TIdMessage.Create(nil);
  SSL := TIdSSLIOHandlerSocketOpenSSL.Create(nil);
 
  SSL.SSLOptions.Method := sslvTLSv1;
  SSL.SSLOptions.Mode := sslmUnassigned;
  SSL.PassThrough:=true;
  SSL.SSLOptions.VerifyMode := [];
  SSL.SSLOptions.VerifyDepth := 0;
 
  SMTP.IOHandler := SSL;
  SMTP.UseTLS := utUseExplicitTLS;
  SMTP.Host := 'exchange.ccccloud.com';
  SMTP.Port := 25;
  SMTP.username := username;
  SMTP.password := password;
 
  DATA.From.Address := username;
  DATA.Recipients.EMailAddresses := totarget;
  DATA.subject := subject;
  DATA.body.text := body;
 
  try
     try
       SMTP.Connect;
       SMTP.Send(DATA) ;
     except on E:Exception do
            ShowMessage(E.Message) ;
     end;
   finally
      if SMTP.Connected then SMTP.Disconnect;
   end;
   SMTP.Free;
   DATA.Free;
   SSL.Free;
end;


here is how i call the procedure
SendEmail('myemail', 'password' , 'emailto' , 'subject' , 'body');


thank you very much for the helpers

Edited by: Yaniv Haliwa on Jul 15, 2017 9:21 AM

Edited by: Yaniv Haliwa on Jul 15, 2017 2:06 PM
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02