EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Send e-mail using TLS

Also by EldoS: Solid File System
A virtual file system that offers a feature-rich storage for application documents and data with built-in compression and encryption.
#28896
Posted: 03/21/2014 11:32:38
by Eduardo Helminsky (Standard support level)
Joined: 08/20/2010
Posts: 102

Hi

I have been trying send an email using TLS but it does not work. The routine works with SSL. What am I missing ? Do I have to set another property ?
Code
FSmtp.Address := FHost;
FSmtp.Port := FPort;
FSmtp.Username := FUsername;
FSmtp.Password := FPassword;
if FCript in [scSSL,scTLS] then begin
   FSmtp.UseSSL := True;
   FSmtp.SSLMode := smImplicit;
   FSmtp.OnCertificateValidate := CertificateValidateHandler;
end;
FSmtp.Open;              <--- Here I receive 75777 error

procedure TSMTP.CertificateValidateHandler(Sender : TObject; X509Certificate : TElX509Certificate; var Validate : Boolean);
begin
     Validate := true;
end;
#28897
Posted: 03/21/2014 11:37:30
by Eugene Mayevski (EldoS Corp.)

What did you mean by saying that TLS doesn't work and SSL works? Did you try different SSL/TLS versions and some of them worked, while others didn't?

Are you sure that you need to use implicit mode? What port are you connecting to?


Sincerely yours
Eugene Mayevski
#28898
Posted: 03/21/2014 11:51:40
by Eduardo Helminsky (Standard support level)
Joined: 08/20/2010
Posts: 102

Sorry for not detail the issue.

What I mean is the base code is working without SSL connecting to servers that do not need security and the code works with G-MAIL that uses SSL.

I am trying to connect to Office365 e-mail account using SMTP server "SMTP.office365.com", port 587. This server requires TLS but I am not sure if I need or not use implicit mode.

I tried with SSL := smExplicit and it connects to the server but fails at login.
#28899
Posted: 03/21/2014 11:54:52
by Eugene Mayevski (EldoS Corp.)

Port 587 is for unprotected mail and optionally for explicit SSL/TLS.

What exactly fails on login?


Sincerely yours
Eugene Mayevski
#28900
Posted: 03/21/2014 11:57:53
by Eugene Mayevski (EldoS Corp.)

Also try to set Versions property of the client to include ONLY SSL3. This should help, at least it did help other users.


Sincerely yours
Eugene Mayevski
#28901
Posted: 03/21/2014 12:29:00
by Eduardo Helminsky (Standard support level)
Joined: 08/20/2010
Posts: 102

Eugene

Fantastic support.

The TLS is working now. Thank you very much for you prompt response.

Regards

The final code:
if FCript = scSSL then begin
FSmtp.UseSSL := True;
FSmtp.SSLMode := smImplicit;
FSmtp.OnCertificateValidate := CertificateValidateHandler;
end else if FCript = scTLS then begin
FSmtp.UseSSL := True;
FSmtp.SSLMode := smExplicit;
FSmtp.OnCertificateValidate := CertificateValidateHandler;
FSmtp.Versions := [sbSSL3];
end else begin
FSmtp.UseSSL := False;
FSmtp.OnCertificateValidate := nil;
end;

Eduardo
Also by EldoS: RawDisk
Access locked and protected files in Windows, read and write disks and partitions and more.

Reply

Statistics

Topic viewed 500 times

Number of guests: 1, registered members: 0, in total hidden: 0




|

Back to top

As of July 15, 2016 EldoS Corporation will operate as a division of /n software inc. For more information, please read the announcement.

Got it!