PDA

View Full Version : PHP in Qt



ionutdanila
9th January 2011, 11:27
Hello!

I have to send some e-mails from my Qt application, but I couldn't find something in Qt to help me with that. So I need to use mail() from PHP to send e-mails. But how can I do that?

How can I execute a PHP script from Qt? (I know I can use QProcess, but is there any library that would actually recognize PHP code?)

Is there any way to send e-mail from Qt? (I know there was something in Qt3, but I don't know how to do it in Qt4)

tbscope
9th January 2011, 11:41
http://libqxt.bitbucket.org/doc/0.6/classes.html
http://dev.libqxt.org/libqxt/wiki/Home

Lykurg
9th January 2011, 11:43
Or have a look at QwwSmtpClient (http://blog.wysota.eu.org/index.php/2009/03/12/qwwsmtpclient/).

ionutdanila
9th January 2011, 14:08
Thank you for your help. I am using QwwSmtpClient, but here is another problem:



QwwSmtpClient client;
connect(&client, SIGNAL(sslErrors(const QList<QSslError> &)), &client, SLOT(ignoreSslErrors()));
client.connectToHost("mail.gmx.com");
client.startTls();
client.authenticate("TopMovieS", "xxxxx", QwwSmtpClient::AuthLogin);
client.sendMail("TopMovieS@gmx.us", destinatari, message);
client.disconnectFromHost();


This is the code that I wrote to connect to smtp and send the message, but the message is not sent (received). I don't think I am doing something wrong. Can anyone help me?

Lykurg
9th January 2011, 14:45
What does QwwSmtpClient::errorString() says and debug the sslErrors.

ionutdanila
9th January 2011, 17:33
So I Debug QwwSmtpClient::errorString() with qDebug() and nothing...



void QwwSmtpClient::ignoreSslErrors() {
d->socket->ignoreSslErrors();
}




QString QwwSmtpClient::errorString() const{
qDebug()<<errorString();
return d->errorString;
}


I don't know if this is what you said....

I still can't send e-mails... even if in qDebug() it returns 1-5 values from the functions in my previous post, my e-mail doesn't get to the destination...

wysota
9th January 2011, 17:45
What does destinatari contain? What does message contain?

ionutdanila
9th January 2011, 19:04
//destinatari and message are 2 variables from sendMail
int QwwSmtpClient::sendMail(const QString & from, const QStringList & to, const QString & content) {




string mesaj="From: TopMovieS@gmx.us\r\nTo: "+to+"\r\nSubject: TopMovie Notification\r\n\r\n";
mesaj=mesaj+"Congratulations, \r\n\r\nYour uploaded Movie, \""+film+"\", is First in "+genre+" Top with "+votes+" votes!\r\n\r\n";
mesaj=mesaj+"TopMovie Server";

QString message=mesaj.c_str();

QStringList destinatari=QString(to.c_str()).split(";");

wysota
9th January 2011, 20:38
Get a network sniffer, disable tls and check what exactly gets sent to the mail server and what the server answers. If you don't have a network sniffer, you can use this one: http://www.qtcentre.org/threads/34082-NetworqDebugger