Einzelnen Beitrag anzeigen

Digielm

Registriert seit: 2. Aug 2006
246 Beiträge
 
Delphi 5 Enterprise
 
#1

Delphi 2007 .net INDY 10.5 mit TLS / SSL Fehler BUFFER TERMINATOR must be specified

  Alt 17. Jan 2011, 12:27
Delphi-Version: 2007
Hallo Leute,

ich habe ein kleines Problem

ich hab einen Source gefunden mit dem ich Mails via SMTP mit TLS / SSL versenden kann.

Ich habe jetzt versucht das ganze auch mit Delphi 2007 dot NET umzusetzen, leider kriege ich das nicht so ganz hin.

Kann mir jemand damit helfen wie ich in dot net SLL / TLS mit Indy 10.5.7 via SMTP machen kann.

Als Fehlermeldung erhalte ich immer
"BUFFER TERMINATOR must be specified'

Kann jemand damit was anfangen ?

Delphi-Quellcode:
var
   MsgSend:TIdMessage;
   SMTP:TIdSMTP;
   SASLNTLM : TIdSASLLogin;
   UserPassProv:TIdUserPassProvider;
   sentOK:Boolean;
   sslhandler : TIdSSLIOHandlerSocketNET;
begin
  MsgSend:=TIdMessage.Create; //create the message
  with MsgSend do
     begin
        Body.Text:=#13+'Dies ist eine Test E-Mail';
        From.Text := edsmtpusermailaddress.text;
        Recipients.EMailAddresses := edsmtpusermailaddress.text;
        Subject := 'Info E-Mail durch '+caption; // set the subject
        Priority := mpNormal; // set the priority (note that you could add to
                               // Destination to support different priorities)
     end;
  try
    SMTP:=TIdSMTP.Create; //create the SMTP object
    try
      smtp.IOHandler := TIdSSLIOHandlerSocketNET.create; //if we succeed, then we can create a SSL socket handler and assign it to the IOHandler
      smtp.UseTLS := utUseExplicitTLS; //and we can mark the we can use tls

    except
      smtp.IOHandler := TIdIOHandler.MakeDefaultIOHandler(smtp); //the SSL failed to create, so make the default IO handler
      smtp.UseTLS := utNoTLSSupport; //mark that we have no TLS support
   end;
   smtp.ManagedIOHandler := True; //either way, we now have a ManagedIOHandler

    try
      SMTP.AuthType := satSASL;
      SMTP.UserName := 'SMTPUSERNAME'; // User Input
      SMTP.Password := 'SMTPPASSWORD'; // User Input

      userPassProv:=TIdUserPassProvider.Create; //create the user/pass provider - this handles the login functions for SASL
      userPassProv.UserName:=SMTP.UserName; // setup user name
      userPassProv.Password:=SMTP.Password; // & password

      if SMTP.AuthType=satSASL then //if we are going to use SASL - basically, SASL just encrypts the login, everything else is still clear text
        begin
         SASLNTLM := TIdSASLLogin.Create;
         SASLNTLM.UserPassProvider:=userPassProv;
         SMTP.SASLMechanisms.Clear;
         SMTP.SASLMechanisms.Add.SASL:=SASLNTLM;
        end;
      {General setup}
      SMTP.Host := 'smtpip'; //setup the server name
      SMTP.Port := 25; //setup the server port

      {now we send the message}
      SMTP.ConnectTimeout := 1000;
      SMTP.Connect;
      if not SMTP.Authenticate then //authenticate with the server - this will automatically use SASL if configured and supported
      begin
        MessageDlg('An error occurred attempting to send your e-mail. The error was : Unable to authenticate.', mtError, [mbOK], 0);
        exit;
      end;
      try
         try
// ShowMessage('Before Send');
           SMTP.Send(MsgSend); //send the message
// ShowMessage('After Send');
           SentOk:=true; //indicate success
         finally
            SMTP.Disconnect; //disconnect from the server
         end;
      except on E :Exception do //if we had a failure, say so
         begin
         MessageDlg('An error occurred attempting to send your e-mail. The error was : '+E.Message, mtError, [mbOK], 0);
         SentOk:=false; //set failure
         end;
      end;
    finally
    SMTP.Free; //free the memory
    end;
  finally
// if logFile<>nil then //if we had a log file, free that
// logFile.Free;
     MsgSend.Free; //free the message
  end;
  Mit Zitat antworten Zitat