I have a smtp auth connection and is ready to read qt4...



now i send
1- ehlo localhost
-------server
250-remote.com
250-STARTTLS
250-PIPELINING
250-8BITMIME
250-SIZE 0
250 AUTH LOGIN PLAIN CRAM-MD5
-------server
2- auth user@domaine.com
3- 334 VXNlcm5hbWU6
-------server
235 authentication finished successfully
-------server
4- mail from: user@domaine.com
Data .....
and wait...
-------server
221 Bye
-------server

..... How to create a CRAM-MD5 password on QT?

Qt Code:
  1. Smtp::Smtp( const QString &from, const QString &to, const QString &subject, const QString &body )
  2. {
  3.  
  4. const QString smtphost = "ppk.go";
  5. const int Timeout = 5 * 1000;
  6. linesend = 0;
  7. qDebug() << "### Launch mail compose.... " << from << to << subject << body;
  8. qDebug() << "### Config server smtp connect to...... " << smtphost;
  9. smtpsocket = new QTcpSocket(this);
  10. connect( this, SIGNAL(ConnectorSuccess()), this ,SLOT(ReadLiner()));
  11. connect( this, SIGNAL(SendLine()), this ,SLOT(PutSendLine()));
  12. smtpsocket->connectToHost(smtphost,25);
  13. if (smtpsocket->waitForConnected(Timeout)) {
  14. qDebug() <<"### connected on " << smtphost;
  15. if (smtpsocket->waitForReadyRead(Timeout)) {
  16. qDebug() <<"### emit from waitForReadyRead connect go can read";
  17. emit ConnectorSuccess();
  18. }
  19. }
  20.  
  21. }
  22.  
  23. void Smtp::ReadLiner()
  24. {
  25. qDebug() << "### socketType = " << smtpsocket->socketType();
  26. qDebug() << "### ReadLiner is start by textstream ";
  27. t = new QTextStream( smtpsocket );
  28. int loops = 0;
  29. while (!t->atEnd()) {
  30. loops++;
  31. response = t->readLine();
  32. qDebug() << loops << " in line " << response;
  33. }
  34. if (response.size() > 0) {
  35. RemoteServerName = response;
  36. mailstatus = response.left(3);
  37. qDebug() << "###Status=" << mailstatus;
  38. if (mailstatus == "220") {
  39. linesend = 1;
  40. emit SendLine();
  41. }
  42. }
  43. }
To copy to clipboard, switch view to plain text mode