Results 1 to 9 of 9

Thread: PHP in Qt

  1. #1
    Join Date
    Dec 2010
    Posts
    8
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question PHP in Qt

    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)

  2. #2
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

  3. The following user says thank you to tbscope for this useful post:

    homerun4711 (9th January 2011)

  4. #3
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: PHP in Qt

    Or have a look at QwwSmtpClient.

  5. The following user says thank you to Lykurg for this useful post:

    ionutdanila (9th January 2011)

  6. #4
    Join Date
    Dec 2010
    Posts
    8
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: PHP in Qt

    Thank you for your help. I am using QwwSmtpClient, but here is another problem:

    Qt Code:
    1. QwwSmtpClient client;
    2. connect(&client, SIGNAL(sslErrors(const QList<QSslError> &)), &client, SLOT(ignoreSslErrors()));
    3. client.connectToHost("mail.gmx.com");
    4. client.startTls();
    5. client.authenticate("TopMovieS", "xxxxx", QwwSmtpClient::AuthLogin);
    6. client.sendMail("TopMovieS@gmx.us", destinatari, message);
    7. client.disconnectFromHost();
    To copy to clipboard, switch view to plain text mode 

    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?

  7. #5
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: PHP in Qt

    What does QwwSmtpClient::errorString() says and debug the sslErrors.

  8. #6
    Join Date
    Dec 2010
    Posts
    8
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: PHP in Qt

    So I Debug QwwSmtpClient::errorString() with qDebug() and nothing...

    Qt Code:
    1. void QwwSmtpClient::ignoreSslErrors() {
    2. d->socket->ignoreSslErrors();
    3. }
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. QString QwwSmtpClient::errorString() const{
    2. qDebug()<<errorString();
    3. return d->errorString;
    4. }
    To copy to clipboard, switch view to plain text mode 

    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...

  9. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: PHP in Qt

    What does destinatari contain? What does message contain?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  10. #8
    Join Date
    Dec 2010
    Posts
    8
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: PHP in Qt

    Qt Code:
    1. //destinatari and message are 2 variables from sendMail
    2. int QwwSmtpClient::sendMail(const QString & from, const QStringList & to, const QString & content) {
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. string mesaj="From: TopMovieS@gmx.us\r\nTo: "+to+"\r\nSubject: TopMovie Notification\r\n\r\n";
    2. mesaj=mesaj+"Congratulations, \r\n\r\nYour uploaded Movie, \""+film+"\", is First in "+genre+" Top with "+votes+" votes!\r\n\r\n";
    3. mesaj=mesaj+"TopMovie Server";
    4.  
    5. QString message=mesaj.c_str();
    6.  
    7. QStringList destinatari=QString(to.c_str()).split(";");
    To copy to clipboard, switch view to plain text mode 

  11. #9
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: PHP in Qt

    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
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.