Jump to content

Plainer

Members
  • Content Count

    27
  • Joined

  • Last visited

Posts posted by Plainer


  1. On 9/4/2020 at 10:20 PM, FPiette said:

    Yes, it is. It is show in one of the demos: OverbyteIcsMailHtml.dproj

    Note that you can also send RTF in a similar manner (No demo).

    I had a look at the sample "OverbyteIcsMailHtml", I did not see a way of sending a StartTTLS command, I am sure I must have overlooked it.  Is this possible and where should I look?

     

    Thanks


  2. 14 hours ago, FPiette said:

    You should start the next mail at MailFrom stage.

     

    Not to clear on what you meant, however I did make a change by moving the next record call within the case statement.  It seemed to make matters worse as it no longer sends out an email but still stops after two records. 

     

        smtpMailFrom: begin
                      SendNextRecord;
                      SslSmtpClient.RcptTo;
                      end;

    The solution is simply eluding me, the concept seems simple but proving difficult to do.

     

    Can you provide an example on the correct insertion point for the next record call?

     

    Thanks


  3. 17 minutes ago, FPiette said:

    Are you sure you test all possible error everywhere and don't ignore any exception?

     

    The code you gave yesterday is flawed. Your addition in RequestDone handler to start a new mail do not depend on the RqType but is always executed.

     

    I think you are right, The two emails that do send return the following after sending a email. 

    First email: RequestDone Rq=5 Error=0

    Second email: RequestDone Rq=9 Error=0

     

    I put in a 2 second delay between sends (procedure TEMail_Send.SendNextRecord;) but no real progress, It is on the third email that the system hangs up.

     

    This is the code I am currently working with.

    procedure TEMail_Send.BitBtn4Click(Sender: TObject);
    begin
        DataBase_Mail.GoTop; // not sure about this

        if SslSmtpClient.Connected then begin
            MessageBeep(MB_OK);
            Display('All-In-One demo start in connected state.');
            Display('Please quit or abort the connection first.');
            Exit;
        end;

        FAllInOneFlag               := TRUE;
        FEhloCount                  := 0;
        { Initialize all SMTP component properties from our GUI }
        SslSmtpClient.Host          := wDataBase_Cfg.GetTrimString('CHOST');
        SslSmtpClient.Port          := wDataBase_Cfg.GetTrimString('CPORTHOST');
        SslSmtpClient.SignOn        := wDataBase_Cfg.GetTrimString('CSIGNON');
        SslSmtpClient.FromName      := wDataBase_Cfg.GetTrimString('CFROM');;
        SslSmtpClient.HdrFrom       := wDataBase_Cfg.GetTrimString('CFROM');
        SslSmtpClient.HdrTo         := DataBase_Mail.GetTrimString('COWN1EMAIL');
        SslSmtpClient.HdrCc         := DataBase_Mail.GetTrimString('COWN2EMAIL');
        SslSmtpClient.HdrSubject    := DataBase_EMailText.GetString('CSUBLINE');
        SslSmtpClient.EmailFiles    := nil; // FileAttachMemo.Lines;
        SslSmtpClient.AuthType      := TSmtpAuthType(wDataBase_Cfg.GetInteger('NAUTHTYPE'));
        SslSmtpClient.SslType       := TSmtpSslType(wDataBase_Cfg.GetInteger('NSSLType'));

        if SslSmtpClient.SslType <> smtpTlsNone then begin
            SslContext1.SslPrivKeyFile := ''; //KeyEdit.Text;
            SslContext1.SslPassPhrase  := ''; //PassPhraseEdit.Text;
            SslContext1.SslCertFile    := ''; //CertEdit.Text;
            SslContext1.SslCAFile      := ''; //CAFileEdit.Text;
            SslContext1.SslCAPath      := ''; //CAPathEdit.Text;
            //SslContext1.SslVerifyPeer  := false; //VerifyPeerCheckBox.Checked;
            SslContext1.SslVerifyPeer  := wDataBase_Cfg.GetLogical('LSSLVERPER');
            if SslContext1.SslVerifyPeer then begin
                SslSmtpClient.OnSslVerifyPeer := SslSmtpClientSslVerifyPeer;
                SslSmtpClient.OnSslHandshakeDone := SslSmtpClientSslHandshakeDone;
            end
            else begin
                SslSmtpClient.OnSslVerifyPeer := nil;
                SslSmtpClient.OnSslHandshakeDone := nil;
            end;
        end;

        SslSmtpClient.Username       := wDataBase_Cfg.GetTrimString('CUSERNAME');
        SslSmtpClient.Password       := wDataBase_Cfg.GetTrimString('CPASSWORD');
        SslSmtpClient.HdrPriority    := TSmtpPriority(wDataBase_Cfg.GetInteger('NPriority'));
        { Recipient list is computed from To, Cc and Bcc fields }
        SslSmtpClient.RcptName.Clear;
        //SslSmtpClient.RcptNameAdd(ToEdit.Text, CcEdit.Text, BccEdit.text);
        SslSmtpClient.RcptNameAdd(DataBase_Mail.GetTrimString('COWN1EMAIL'), DataBase_Mail.GetTrimString('COWN2EMAIL'), '');

        Display('Connecting to SMTP server...');
        { Start first operation to do to send an email          }
        { Next operations are started from OnRequestDone event  }

      //BuildRcptList;

      //SendNextEmail;

        SslSmtpClient.Connect;

    end;
    {* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}

     

    procedure TEMail_Send.SslSmtpClientRequestDone(Sender: TObject;
      RqType: TSmtpRequest; ErrorCode: Word);
    begin
        { For every operation, we display the status }
        if (Error > 0) and  (Error < 10000) then
            Display('RequestDone Rq=' + IntToStr(Ord(RqType)) +
                        ' Error='+ SslSmtpClient.ErrorMessage)
        else
            Display('RequestDone Rq=' + IntToStr(Ord(RqType)) +
                                ' Error='+ IntToStr(Error));
        { Check if the user has asked for "All-In-One" demo }
        if not FAllInOneFlag then
            Exit;             { No, nothing more to do here }
        { We are in "All-In-One" demo, start next operation }
        { But first check if previous one was OK            }
        if Error <> 0 then begin
            FAllInOneFlag := FALSE;   { Terminate All-In-One demo }
            Display('Error, stoped All-In-One demo');
            Exit;
        end;
        case RqType of
        smtpConnect:  begin
                          if SslSmtpClient.AuthType = smtpAuthNone then
                              SslSmtpClient.Helo
                          else
                              SslSmtpClient.Ehlo;
                      end;
        smtpHelo:     SslSmtpClient.MailFrom;
        smtpEhlo: if SslSmtpClient.SslType = smtpTlsExplicit then begin
                      Inc(FEhloCount);
                      if FEhloCount = 1 then
                          SslSmtpClient.StartTls
                      else if FEhloCount > 1 then
                          SslSmtpClient.Auth;
                  end
                  else
                      SslSmtpClient.Auth;

        smtpStartTls: SslSmtpClient.Ehlo; // We need to re-issue the Ehlo command
        smtpAuth:     SslSmtpClient.MailFrom;
        smtpMailFrom: SslSmtpClient.RcptTo;
        smtpRcptTo:   SslSmtpClient.Data;

        smtpData:     if DataBase_Mail.Eof then
                         begin
                         SslSmtpClient.Quit;
                         Display('Mail Done !');
                         end
                      else
                         begin
                         if nSentCount = 0 then
                            begin
                            nSentCount := (nSentCount+1);
                            SentCount.Caption := IntToStr(nSentCount);
                            end;
                         SendNextRecord;
                         end;

        smtpQuit:     if DataBase_Mail.Eof then
                         begin
                         Display('Mail Done !');
                         end;
                      //else
                      //   begin
                      //   SendNextRecord;
                      //   end;

        end;
    {*******************************************************************}
    end;

    {* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
    procedure TEMail_Send.SendNextRecord;
    begin
        ShowMessage('Start Test');
        Delay(2000);
        ShowMessage('End Test');

        DataBase_Mail.Skip(1);

        if not DataBase_Mail.Eof then
           begin
           FAllInOneFlag                 := True;
           SslSmtpClient.RcptName.Clear;
           SslSmtpClient.RcptNameAdd(Trim(DataBase_Mail.GetTrimString('COWN1EMAIL')), Trim(DataBase_Mail.GetTrimString('COWN2EMAIL')), '');
           SslSmtpClient.HdrFrom         := wDataBase_Cfg.GetTrimString('CFROM');
           SslSmtpClient.HdrTo           := DataBase_Mail.GetTrimString('COWN1EMAIL');
           SslSmtpClient.HdrCc           := DataBase_Mail.GetTrimString('COWN2EMAIL');
           SslSmtpClient.HdrSubject      := DataBase_EMailText.GetString('CSUBLINE');
           SslSmtpClient.SignOn          := wDataBase_Cfg.GetTrimString('CSIGNON');
           SslSmtpClient.FromName        := wDataBase_Cfg.GetTrimString('CFROM');
           SslSmtpClient.EmailFiles      := nil; // FileAttachMemo.Lines;
           SslSmtpClient.Host            := wDataBase_Cfg.GetTrimString('CHOST');
           SslSmtpClient.Port            := wDataBase_Cfg.GetTrimString('CPORTHOST');
           //SslSmtpClient.SendMode        := smtpCopyToStream;
           SslSmtpClient.Mail;
           if nSentCount > 0 then
              begin
              nSentCount := (nSentCount+1);
              SentCount.Caption := IntToStr(nSentCount);
              end;
           end
        else
           exit;
    end;
    {* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}

     

     

     


  4. On 8/16/2020 at 1:12 AM, Angus Robertson said:

    No point in looking at the code since it is using the wrong component, for the third time.  You are attempting to recreate code that already exists and works in the TIcsMailQueue component.

     

    Angus

     

    Angus, the example you are talking about is similar but different, your example does send out an email to multiple address but keeps the content of the email static, the program I am working on sends out a unique message to each recipient, by walking though a database,

     

    I have a somewhat working model however one small problem and not sure where it stems from, on the third iteration it hangs, does not give an error simply hangs.  I was thinking it maybe a timing issue sending to much to the mail server to quickly.   I was thinking that if I put in a small pause between each email it  may resolve the issue.

     

    Can I send  you a copy of the code for your review and recommendations?

     

    Thank you

    Will


  5. I have been looking over the sample program and was wondering if I am on the correct path, I was going to give the following a try but wanted some input first.

     

    I was thinking that I can send the next email by using the ClientRequestDone event.

     

    I made my additions in bold text so you can see them.

     

     

    {* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
    procedure TSslSmtpTestForm.SslSmtpClientRequestDone(
        Sender : TObject;
        RqType : TSmtpRequest;
        Error  : Word);
    begin
        { For every operation, we display the status }
        if (Error > 0) and  (Error < 10000) then
            Display('RequestDone Rq=' + IntToStr(Ord(RqType)) +
                        ' Error='+ SslSmtpClient.ErrorMessage)
        else
            Display('RequestDone Rq=' + IntToStr(Ord(RqType)) +
                                ' Error='+ IntToStr(Error));
        { Check if the user has asked for "All-In-One" demo }
        if not FAllInOneFlag then
            Exit;             { No, nothing more to do here }
        { We are in "All-In-One" demo, start next operation }
        { But first check if previous one was OK            }
        if Error <> 0 then begin
            FAllInOneFlag := FALSE;   { Terminate All-In-One demo }
            Display('Error, stoped All-In-One demo');
            Exit;
        end;
        case RqType of
        smtpConnect:  begin
                          if SslSmtpClient.AuthType = smtpAuthNone then
                              SslSmtpClient.Helo
                          else
                              SslSmtpClient.Ehlo;
                      end;
        smtpHelo:     SslSmtpClient.MailFrom;
        smtpEhlo: if SslSmtpClient.SslType = smtpTlsExplicit then begin
                      Inc(FEhloCount);
                      if FEhloCount = 1 then
                          SslSmtpClient.StartTls
                      else if FEhloCount > 1 then
                          SslSmtpClient.Auth;
                  end
                  else
                      SslSmtpClient.Auth;
        smtpStartTls: SslSmtpClient.Ehlo; // We need to re-issue the Ehlo command
        smtpAuth:     SslSmtpClient.MailFrom;
        smtpMailFrom: SslSmtpClient.RcptTo;
        smtpRcptTo:   SslSmtpClient.Data;

    {* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
    // Check database for EOF if True then finish
           smtpData:     SslSmtpClient.Quit;
           smtpQuit:     Display('All-In-One done !');
          exit;
    {* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}

        end;

     

    {* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
    // Send next email
    // Get next record reload component and send
        SslSmtpClient.RcptName.Clear;
        SslSmtpClient.RcptNameAdd(ToEdit.Text, CcEdit.Text, BccEdit.text);
        SslSmtpClient.HdrFrom         := FromEdit.Text;
        SslSmtpClient.HdrTo           := ToEdit.Text;
        SslSmtpClient.HdrCc           := CcEdit.Text;
        SslSmtpClient.HdrSubject      := SubjectEdit.Text;
        SslSmtpClient.SignOn          := SignOnEdit.Text;
        SslSmtpClient.FromName        := FromEdit.Text;
        SslSmtpClient.EmailFiles      := FileAttachMemo.Lines;
        SslSmtpClient.SendMode        := smtpCopyToStream;
        SslSmtpClient.Mail;
    {* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}

    end;

     


  6. I am trying to create an email program that will send a email to mutable email addresses by reading in a database file and sending out a

    email / newsletter to each record in the database. (for my wife's sewing club)
     
    I have been using the "OverbyteIcsSslMailSnd" sample / demo program as an guide.

     

    Everything works correctly if I select a record and the send the email. The problem I am having is trying to figure out a way to send the

    email to each listed email in the database automatically.

     

    I can not find a direct means to send the batch of emails, I was thinking that if  within the "All In One" button I added a while loop to repeat

    the process until the database is empty, however that did not work.

     

    So next I tried was to add a test button that calls the "All In One" button using the .click method of the button.


    Procedure
    Newbutton
    Database gotop

    while not database.eof do
    begin
      allinonebutton.click;
      skip database one record;
    end;

     

    The problem I am having on the second loop "Record 2" I receive a error "SMTP Component not ready".

     

    I am thinking that I may need some sort of a delay timer between iterations.

     

    What am I overlooking?


    Thanks
    Will


  7. I have been unable to determine requirements that smtp.aol.com is looking for.

     

    I am using the follwing:

        Server Address: smtp.aol.com.
        Username: Your AOL Mail screen name (e.g. whatever comes before @aol.com)
        Password: Your AOL Mail password.
        Port Number: 587 (With TLS)
        Alternative Port Number: 465 (With SSL)
        Authentication: Required.

     

    However I cannot make a connection to send an email. I think that AOL is using a Yahoo backbone but not to sure.

     

    Any ideas on what I am overlooking?

     

    Thanks

     

     


  8. Ok, this is my confirmation from the server.

     

     

    Your request has been sent and you should receive a copy delivered to your mailbox within a few minutes.

    If the email does not arrive, this is probably because you have entered an incorrect email address, so you should
    return to the form and check the address, otherwise you probably won't receive the password email either. 


  9. I am trying to learn how to send a SMTP email that uses StartTLS.

     

    I am looking for a working demo program that sends SMTP emails that also can issue a StartTLS command.

    I have looked at both the OverbyteIcsSslMailSnd and OverbyteIcsMailQuTst demo programs.  The OverbyteIcsSslMailSnd has a runtime execption error when the StartTLS is issued "via button" and "All In One" Button.  I have also tried the OverbyteIcsSslMailSnd demo program but receive an error too when it tries to make a secure connection the error I receive is "Failed to Initialise SSL - Must load LIBEAY DLL before SSLEAY"

     

    If anyone can share a working example demo program for sending emails using the ICS suite, it will be very much appreciated.

     

    I am using Delphi7 with the ICS864 component suite.

     

    Thank you
    William


  10. I was able to compile the OverbyteIcsMailQuTst demo program however when I try send a mail I get the following:

     

    Opened log file: f:\eMail Demo 2\ics-mailqu-2020-08-06.log
    Failed to Initialise SSL - Must load LIBEAY DLL before SSLEAY

     

    I also received the following:

     

    < 530 5.7.0 Must issue a STARTTLS command first. y128sm10201745pfy.74 - gsmtp

    Failed to Send Mail Item 5 - 530 5.7.0 Must issue a STARTTLS command first. y128sm10201745pfy.74 - gsmtp

     

    Any help is welcome. 

    Thanks

×