SMTP Library fix
-
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?
-
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.
@MEMekaniske
I'm not sure what changes Qt6 might have made, but doesQString 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.... -
What is type is
tanduser? -
What is type is
tanduser? -
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?
@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
passisQStringtoo)? -
@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
passisQStringtoo)?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.
-
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.
@MEMekaniske
I'm not sure what changes Qt6 might have made, but doesQString 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.... -
@MEMekaniske
I'm not sure what changes Qt6 might have made, but doesQString 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....@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!
-
@MEMekaniske
I'm not sure what changes Qt6 might have made, but doesQString 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....@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)
-
@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)
@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-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!!
@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... -
@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...@Christian-Ehrlicher
I didn't even notice the.toBase64()bit, I was just trying to get OP through theQByteArray().append(user)=> Here Qt says no matching member function for call to append bit!