Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. SMTP Library fix
Qt 6.11 is out! See what's new in the release blog

SMTP Library fix

Scheduled Pinned Locked Moved Solved General and Desktop
11 Posts 3 Posters 954 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    MEMekaniske
    wrote on last edited by
    #1

    Hello,

    I'm trying to take in use the library put forward in this post, https://forum.qt.io/topic/29280/simple-tls-ssl-supported-smtp-client-for-qt5

    I've managed to correct everything and implement it into my QML application, except for these two append to bytearray lines..

        else if (state == User && responseLine == "334")
        {
            //Trying User
            qDebug() << "Username";
    
    /* Here Qt says no matching member function for call to append, but i have not done anything to it, and people seem to have no issue using it, so wonder what I need to do? */
    
            *t << QByteArray().append(user).toBase64()  << "\r\n";   
            t->flush();
    
            state = Pass;
        }
        else if (state == Pass && responseLine == "334")
        {
            //Trying pass
            qDebug() << "Pass";
            *t << QByteArray().append(pass).toBase64() << "\r\n";
            t->flush();
    
            state = Mail;
        }
    

    Any suggestion? is this because I use it with qt 6 and not 4-5 as suggested?

    JonBJ 1 Reply Last reply
    0
    • M MEMekaniske

      @JonB

      Hey, yeah, sorry I did not write it down in the code, but as noted at the top of my post, I do get the error at both append lines.

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #6

      @MEMekaniske
      I'm not sure what changes Qt6 might have made, but does

      QString provides the following three functions that return a const char * version of the string as QByteArray: toUtf8(), toLatin1(), and toLocal8Bit().

      e.g.

       *t << QByteArray().append(user.toUtf8()).toBase64()  << "\r\n"; 
      

      get rid of the error?

      No, not sure that's right! What about user.toLatin1().data()?

      TBH you can find out whether this is indeed the issue by just trying

       *t << QByteArray().append("a string").toBase64()  << "\r\n"; 
      

      Either that fixes the problem (proving its a char * issue) or it does not....

      M Christian EhrlicherC 2 Replies Last reply
      1
      • Christian EhrlicherC Offline
        Christian EhrlicherC Offline
        Christian Ehrlicher
        Lifetime Qt Champion
        wrote on last edited by
        #2

        What is type is t and user?

        Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
        Visit the Qt Academy at https://academy.qt.io/catalog

        M 1 Reply Last reply
        0
        • Christian EhrlicherC Christian Ehrlicher

          What is type is t and user?

          M Offline
          M Offline
          MEMekaniske
          wrote on last edited by
          #3

          @Christian-Ehrlicher

          Hey :)

          *t is QTextStream and user is QString

          1 Reply Last reply
          0
          • M MEMekaniske

            Hello,

            I'm trying to take in use the library put forward in this post, https://forum.qt.io/topic/29280/simple-tls-ssl-supported-smtp-client-for-qt5

            I've managed to correct everything and implement it into my QML application, except for these two append to bytearray lines..

                else if (state == User && responseLine == "334")
                {
                    //Trying User
                    qDebug() << "Username";
            
            /* Here Qt says no matching member function for call to append, but i have not done anything to it, and people seem to have no issue using it, so wonder what I need to do? */
            
                    *t << QByteArray().append(user).toBase64()  << "\r\n";   
                    t->flush();
            
                    state = Pass;
                }
                else if (state == Pass && responseLine == "334")
                {
                    //Trying pass
                    qDebug() << "Pass";
                    *t << QByteArray().append(pass).toBase64() << "\r\n";
                    t->flush();
            
                    state = Mail;
                }
            

            Any suggestion? is this because I use it with qt 6 and not 4-5 as suggested?

            JonBJ Offline
            JonBJ Offline
            JonB
            wrote on last edited by JonB
            #4

            @MEMekaniske said in SMTP Library fix:

            /* Here Qt says no matching member function for call to append, but i have not done anything to it, and people seem to have no issue using it, so wonder what I need to do? */
            
                *t << QByteArray().append(user).toBase64()  << "\r\n";   
            

            Do you not get the same error on later line:

             *t << QByteArray().append(pass).toBase64() << "\r\n";
            

            (assuming pass is QString too)?

            M 1 Reply Last reply
            0
            • JonBJ JonB

              @MEMekaniske said in SMTP Library fix:

              /* Here Qt says no matching member function for call to append, but i have not done anything to it, and people seem to have no issue using it, so wonder what I need to do? */
              
                  *t << QByteArray().append(user).toBase64()  << "\r\n";   
              

              Do you not get the same error on later line:

               *t << QByteArray().append(pass).toBase64() << "\r\n";
              

              (assuming pass is QString too)?

              M Offline
              M Offline
              MEMekaniske
              wrote on last edited by
              #5

              @JonB

              Hey, yeah, sorry I did not write it down in the code, but as noted at the top of my post, I do get the error at both append lines.

              JonBJ 1 Reply Last reply
              0
              • M MEMekaniske

                @JonB

                Hey, yeah, sorry I did not write it down in the code, but as noted at the top of my post, I do get the error at both append lines.

                JonBJ Offline
                JonBJ Offline
                JonB
                wrote on last edited by JonB
                #6

                @MEMekaniske
                I'm not sure what changes Qt6 might have made, but does

                QString provides the following three functions that return a const char * version of the string as QByteArray: toUtf8(), toLatin1(), and toLocal8Bit().

                e.g.

                 *t << QByteArray().append(user.toUtf8()).toBase64()  << "\r\n"; 
                

                get rid of the error?

                No, not sure that's right! What about user.toLatin1().data()?

                TBH you can find out whether this is indeed the issue by just trying

                 *t << QByteArray().append("a string").toBase64()  << "\r\n"; 
                

                Either that fixes the problem (proving its a char * issue) or it does not....

                M Christian EhrlicherC 2 Replies Last reply
                1
                • JonBJ JonB

                  @MEMekaniske
                  I'm not sure what changes Qt6 might have made, but does

                  QString provides the following three functions that return a const char * version of the string as QByteArray: toUtf8(), toLatin1(), and toLocal8Bit().

                  e.g.

                   *t << QByteArray().append(user.toUtf8()).toBase64()  << "\r\n"; 
                  

                  get rid of the error?

                  No, not sure that's right! What about user.toLatin1().data()?

                  TBH you can find out whether this is indeed the issue by just trying

                   *t << QByteArray().append("a string").toBase64()  << "\r\n"; 
                  

                  Either that fixes the problem (proving its a char * issue) or it does not....

                  M Offline
                  M Offline
                  MEMekaniske
                  wrote on last edited by
                  #7

                  @JonB that did indeed take care of it!

                  Tried utf8 first, that worked,
                  also toLatin1().data() seems to work.

                  so it was a charset issue

                  Thank you very much for your help!

                  1 Reply Last reply
                  0
                  • JonBJ JonB

                    @MEMekaniske
                    I'm not sure what changes Qt6 might have made, but does

                    QString provides the following three functions that return a const char * version of the string as QByteArray: toUtf8(), toLatin1(), and toLocal8Bit().

                    e.g.

                     *t << QByteArray().append(user.toUtf8()).toBase64()  << "\r\n"; 
                    

                    get rid of the error?

                    No, not sure that's right! What about user.toLatin1().data()?

                    TBH you can find out whether this is indeed the issue by just trying

                     *t << QByteArray().append("a string").toBase64()  << "\r\n"; 
                    

                    Either that fixes the problem (proving its a char * issue) or it does not....

                    Christian EhrlicherC Offline
                    Christian EhrlicherC Offline
                    Christian Ehrlicher
                    Lifetime Qt Champion
                    wrote on last edited by
                    #8

                    @JonB said in SMTP Library fix:

                    QByteArray().append(user.toUtf8()).toBase64()

                    user.toUtf8().toBase64() please...

                    I'm not sure what changes Qt6 might have made

                    The implicit conversion from a QString to a QByteArray was removed (finally)

                    Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                    Visit the Qt Academy at https://academy.qt.io/catalog

                    JonBJ 1 Reply Last reply
                    0
                    • Christian EhrlicherC Christian Ehrlicher

                      @JonB said in SMTP Library fix:

                      QByteArray().append(user.toUtf8()).toBase64()

                      user.toUtf8().toBase64() please...

                      I'm not sure what changes Qt6 might have made

                      The implicit conversion from a QString to a QByteArray was removed (finally)

                      JonBJ Offline
                      JonBJ Offline
                      JonB
                      wrote on last edited by JonB
                      #9

                      @Christian-Ehrlicher said in SMTP Library fix:

                      user.toUtf8().toBase64() please...

                      When you are prepared to sit down and spend a day explaining UTF, UNICODE, wide chars, multi-byte chars, codecs and everything else of that nature to me I will happily (appreciatively) listen, learn, understand and adjust my code. I have tried many times to understand them all, how they work, how they interact and how/when to use which, and have never grasped it. Hence I just use 8-bit ASCII characters, do not deal with anything other than English/C locales, and give up on the whole area! :(

                      The implicit conversion from a QString to a QByteArray was removed (finally)

                      Ahh!!

                      Christian EhrlicherC 1 Reply Last reply
                      0
                      • JonBJ JonB

                        @Christian-Ehrlicher said in SMTP Library fix:

                        user.toUtf8().toBase64() please...

                        When you are prepared to sit down and spend a day explaining UTF, UNICODE, wide chars, multi-byte chars, codecs and everything else of that nature to me I will happily (appreciatively) listen, learn, understand and adjust my code. I have tried many times to understand them all, how they work, how they interact and how/when to use which, and have never grasped it. Hence I just use 8-bit ASCII characters, do not deal with anything other than English/C locales, and give up on the whole area! :(

                        The implicit conversion from a QString to a QByteArray was removed (finally)

                        Ahh!!

                        Christian EhrlicherC Offline
                        Christian EhrlicherC Offline
                        Christian Ehrlicher
                        Lifetime Qt Champion
                        wrote on last edited by
                        #10

                        @JonB I'm not sure what the encoding of SMTP is but I doubt it's anything other than UTF-8.
                        But I was more on the crude QByteArray().append() stuff - maybe it was a result of 'how to make it complicated' contest...

                        Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                        Visit the Qt Academy at https://academy.qt.io/catalog

                        JonBJ 1 Reply Last reply
                        0
                        • Christian EhrlicherC Christian Ehrlicher

                          @JonB I'm not sure what the encoding of SMTP is but I doubt it's anything other than UTF-8.
                          But I was more on the crude QByteArray().append() stuff - maybe it was a result of 'how to make it complicated' contest...

                          JonBJ Offline
                          JonBJ Offline
                          JonB
                          wrote on last edited by
                          #11

                          @Christian-Ehrlicher
                          I didn't even notice the .toBase64() bit, I was just trying to get OP through the QByteArray().append(user) => Here Qt says no matching member function for call to append bit!

                          1 Reply Last reply
                          0

                          • Login

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • Users
                          • Groups
                          • Search
                          • Get Qt Extensions
                          • Unsolved