EldoS | Feel safer!

Software components for data protection, secure storage and transfer

ElSMTPClient

Also by EldoS: BizCrypto
Components for BizTalk® and SQL Server® Integration Services that let you securely store and transfer information in your business automation solutions.
#10710
Posted: 07/31/2009 07:43:52
by WebSerGe  (Basic support level)
Joined: 07/30/2009
Posts: 6

Code
procedure TForm1.Button1Click(Sender: TObject);
var

msg: TElMessage;
mmp: TElMultiPartList;
mpt: TElPlainTextPart;
mpc: TElMessagePart;
begin
msg := nil;
mmp := nil;
msg := TElMessage.Create(False);
mpt := TElPlainTextPart.Create(msg, mmp);
msg.SetMainPart(mpt, False);
mpt.SetText( mlog.Text );
msg.From.AddAddress('e-mail: '+eUser.Text, eUser.Text);
msg.To_.AddAddress('', mTo.Lines.Strings[0]);
msg.SetSubject(ePort.Text);
msg.SetDate(Now);
msg.MessageID := msg.GenerateMessageID;
ElSMTPClient1.Address:=eAddress.Text;
ElSMTPClient1.Username:=eUser.Text;
ElSMTPClient1.Password:=ePassw.Text;
ElSMTPClient1.WebTunnelAddress:=eWebTunAddr.Text;
ElSMTPClient1.WebTunnelPassword:=eWebTunPassw.Text;
ElSMTPClient1.WebTunnelUserId:=eWebTunUser.Text;
if cbUSETLS.Checked then
begin
  ElSMTPClient1.UseSSL:=True;
  if CheckBox2.Checked then ElSMTPClient1.Versions:= ElSMTPClient1.Versions+ [sbSSL2];
  if CheckBox3.Checked then ElSMTPClient1.Versions:= ElSMTPClient1.Versions+ [sbSSL3];
  if CheckBox4.Checked then ElSMTPClient1.Versions:= ElSMTPClient1.Versions+ [sbTLS1];
  if CheckBox5.Checked then ElSMTPClient1.Versions:= ElSMTPClient1.Versions+ [sbTLS11];
  if CheckBox6.Checked then ElSMTPClient1.Versions:= ElSMTPClient1.Versions+ [sbTLS12];
end
else ElSMTPClient1.UseSSL:=False;

ElSMTPClient1.Port:=StrToInt(ePort.Text);
mlog.Lines.Add(IntToStr(ElSMTPClient1.ProxyResult));
ElSMTPClient1.Open();
ElSMTPClient1.StartTLS;
mlog.Lines.Add( 'Start TLS');
mlog.Lines.Add( IntToStr(ElSMTPClient1.ProxyResult));
ElSMTPClient1.Login(eDomain.Text);// empty
if ElSMTPClient1.Active then mlog.Lines.Add('ElSMTPClient1.Active');
ElSMTPClient1.Send(msg);
ElSMTPClient1.Close(True);
msg.Free;
end;

procedure TForm1.ElSMTPClient1Error(Sender: TObject; ErrorCode: Integer;
  Fatal, Remote: Boolean);
begin
mlog.Lines.Add('OnError Code is '+IntToStr(ErrorCode)+' Fatal is'+ BoolToStr(Fatal)+' remote is '+BoolToStr(Remote));
end;

procedure TForm1.ElSMTPClient1CertificateValidate(Sender: TObject;
  X509Certificate: TElX509Certificate; var Validate: Boolean);
begin
mlog.Lines.Add('ElSMTPClient1CertificateValidate:'+BoolToStr(Validate));
Validate := True;
mlog.Lines.Add('ElSMTPClient1CertificateValidate:'+BoolToStr(Validate));
end;


procedure TForm1.ElSMTPClient1Progress(Sender: TObject; Total,
  Current: Int64; var Cancel: Boolean);
begin
mlog.Lines.Add('ElSMTPClient1Progress');
end;

end.



If Validate:=True then shows Message 'Invalid key material' and
ElSMTPClient1CertificateValidate is -1
#10711
Posted: 07/31/2009 08:50:41
by WebSerGe  (Basic support level)
Joined: 07/30/2009
Posts: 6

STARTTLS I have to use after OPEN or after LOGIN
#10712
Posted: 07/31/2009 08:52:44
by Eugene Mayevski (EldoS Corp.)

You must NOT use StartTLS at all. Implicit mode means that SSL connection is established before higher-level protocol (SMTP in your case) and TLS handshake is performed by the component automatically in Open method.


Sincerely yours
Eugene Mayevski

Reply

Statistics

Topic viewed 6280 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!