Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > General

Lost Password?

Reply
 
Thread Tools Display Modes
  #1  
Old 05-24-2017, 12:03 PM
rmt rmt is offline
Senior Member
 
Join Date: Jun 2013
Posts: 245
Default DelphiXE3: connection closed gracefully in windows12 server

Dear Expert,

I am using TIdSMTP and TIdSSLIOHandlerSocketOpenSSL to send mail from DelphiXE3 application. It was running well but i am getting error when i used this application in windows 12 server. The error is :"Connection Closed Gracefully". Kindly suggest how to overcome this problem: My code is as below:

HTML Code:
Function ConnectServer: Boolean;

begin
Result := False;
  SMTP := TIdSMTP.Create(nil);


  SSLHandler := TIdSSLIOHandlerSocketOpenSSL.Create(nil);


  try
    SSLHandler.MaxLineAction := maException;
    SSLHandler.SSLOptions.Method := sslvTLSv1;
    SSLHandler.SSLOptions.Mode := sslmUnassigned;
    SSLHandler.SSLOptions.VerifyMode := [];
    SSLHandler.SSLOptions.VerifyDepth := 0;

    SMTP.IOHandler := SSLHandler;
    SMTP.Host :=vHost;//smtp.gmail.com
    SMTP.Port := StrToInt(vPort);//587;
    SMTP.Username := vUserId;
    SMTP.Password := vPwd;
    SMTP.UseTLS := utUseExplicitTLS;
    SMTP.ConnectTimeout:=1000000;
    

  except
    on e: Exception do
    begin
      MessageDlg('Error while initializing SMTP server: ' + sLineBreak + e.Message, TMsgDlgType.mtError, [TMsgDlgBtn.mbOK], 0);

    end;
  end;
  
    try
    SMTP.Connect;
    SMTP.Authenticate;
    if SMTP.Connected then
        Result:=True;

    except
    on e: Exception do
    begin
    Result:=False;
      MessageDlg('Cannot connect to SMTP server: ' + sLineBreak + e.Message, TMsgDlgType.mtError, [TMsgDlgBtn.mbOK], 0);

    end;
    end;

end;
__________________
Rmt
Reply With Quote
  #2  
Old 05-24-2017, 01:18 PM
Norrit Norrit is offline
Moderator
 
Join Date: Aug 2001
Location: Landgraaf
Posts: 7,199
Default

Most likely the OpenSSL dll's are missing on your windows 12 server
Reply With Quote
  #3  
Old 05-26-2017, 05:29 AM
rmt rmt is offline
Senior Member
 
Join Date: Jun 2013
Posts: 245
Default

Dear Norrit,

Thank u so much for prompt reply. Both libeay32 and ssleay32.dll exist in windows 12 server. Kindly suggest.

FYI, the error message is "Cannot connect to SMTP server: Connection Closed Gracefully". Just to make sure where exactly the error occurs.

Regards
__________________
Rmt
Reply With Quote
  #4  
Old 05-26-2017, 04:05 PM
rojam rojam is offline
Senior Member
 
Join Date: Jun 2015
Posts: 162
Default

Google restricts access to email from less secure apps. Most likely your application is considered by Google as a less secure app. There's a google e-mail setting your software users will need to change to allow less secure apps to connect to it. See here.
Reply With Quote
  #5  
Old 05-28-2017, 06:01 AM
rmt rmt is offline
Senior Member
 
Join Date: Jun 2013
Posts: 245
Default

Dear Rojam,

We are sending email from same google account from two systems; one with windows 10 and other with windows 12 server. The first one does not have problem in sending email while the windows 12 server is having problem. And the account setting "Allow less secure Apps" is on.

Kindly suggest.
__________________
Rmt
Reply With Quote
  #6  
Old 05-29-2017, 05:58 AM
rmt rmt is offline
Senior Member
 
Join Date: Jun 2013
Posts: 245
Default

Dear Expert,

Please come up with some suggestions.

Regards,
Rashmita
__________________
Rmt
Reply With Quote
  #7  
Old 05-29-2017, 08:35 AM
Norrit Norrit is offline
Moderator
 
Join Date: Aug 2001
Location: Landgraaf
Posts: 7,199
Default

Perhaps adding the IdLogEvent and reading it's info will give you more information on the why?

Other guesses are:
- AntiVirus software (disable to test)
- User privileges (run as administrator to test)
- OpenSSL dll's are not in search path (move them in the application folder to test)
Reply With Quote
  #8  
Old 05-29-2017, 09:42 AM
rmt rmt is offline
Senior Member
 
Join Date: Jun 2013
Posts: 245
Default

Dear Norrit,

Software disabled and test ; not working.
Made Firewall off and test ; not working.
Copied Dll to respective folder and test; Not working.

Now, kindly suggest how shall i add IdLogEvent and read info.

Lots of thanks .
__________________
Rmt
Reply With Quote
  #9  
Old 05-29-2017, 11:08 AM
rmt rmt is offline
Senior Member
 
Join Date: Jun 2013
Posts: 245
Default

Dear Norrit,

the problem is raised on the following line:

SMTP.Authenticate;

Kindly suggest how to proceed further.
__________________
Rmt
Reply With Quote
  #10  
Old 05-29-2017, 12:04 PM
Norrit Norrit is offline
Moderator
 
Join Date: Aug 2001
Location: Landgraaf
Posts: 7,199
Default

Longshot, but you could try setting the UseTLS first and then the Port

Code:
    SMTP.IOHandler := SSLHandler;
    SMTP.Host :=vHost;//smtp.gmail.com
    SMTP.Username := vUserId;
    SMTP.Password := vPwd;
    SMTP.UseTLS := utUseExplicitTLS;
    SMTP.Port := StrToInt(vPort);//587;
    SMTP.ConnectTimeout:=1000000;
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 09:27 PM.


Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2017, vBulletin Solutions, Inc.