Send mail
-
Hi,
From a quick look at the doc:
QxtMailAttachment
QxtMailMessage
QxtSmtpAnd the third result from a google search with
QxtSmtp example
as key words gives a pretty complete example. -
I used git clone https://bitbucket.org/libqxt/libqxt.git for download source code,
I run this commands :
-configure.bat
-configure -debug_and_release
-mingw32-make
-mingw32-make installit's works
but when i compile, i get a message for dynamic links :
_imp___ZN7QxtSmtpC1EP7QObject ...
.pro :
QT+= network QXT+= core gui LIBS+=-LB:/etudes/Programmationastuce/Qt/Bibliotheque/libqxt/lib/ -lQxtCore INCLUDEPATH += B:/etudes/Programmationastuce/Qt/Bibliotheque/libqxt/include/QxtCore \ B:/etudes/Programmationastuce/Qt/Bibliotheque/libqxt/include/QxtNetwork
-
QxtSmtp is is the network module of Qxt not of Qt.
-
Doesn0t look like the same thing. You seem to have errors with Qxt itself or am I misunderstanding ?
-
Did you check the pull request to make it buildable with Qt 5 ?
If not the most simple course of action (and the one the folks behind the library suggests) is to copy the sources of the classes you need in your project.
-
I didn't suggest to delete anything in libqxt.
What I suggested, based on what the authors of the library wrote, is that you copy the files you need inside your project and build them as part of your project.
-
Check this:
https://github.com/dbzhang800/QtMail -
What does the .pro file of your test project look like ?
-
TEMPLATE = app TARGET = test_email INCLUDEPATH += . QT += network # Input HEADERS += qxtglobal.h \ qxtmail_p.h \ qxtmailattachment.h \ qxtmailmessage.h \ qxtsmtp.h \ qxtsmtp_p.h \ qxthmac.h SOURCES += main.cpp \ qxtglobal.cpp \ qxtmailattachment.cpp \ qxtmailmessage.cpp \ qxtsmtp.cpp \ qxthmac.cpp
Is what I have and it's building except I needed to add a forward declaration for QIODevice in qxtmailattachement.h
-
I copied direct, no make , same error in release and debug mode
But why i get this message after execution of mingw32-make ?
I followed this guide https://bitbucket.org/libqxt/libqxt/wiki/user_guidet
-
Did you do a clean rebuild ?
As for the second error, you took the original sources which were written for Qt 4. There has been some changes with Qt 5 so if you want to build Qxt with Qt 5. As I wrote before, you should at least take a look at the pull request related to that.
-
Thaaank, it finally compile, I take the pull request, and i add a #include <QIODevice> in file QxtMailAttachement.h .
but he remain a last problem .
.pro
TEMPLATE = app TARGET = test_email CONFIG += qxt QXT += core QT += network # Input SOURCES += main.cpp INCLUDEPATH+= C:/Qxt/include LIBS+= -LC:/Qxt/bin -lQxtCored -lQxtNetworkd -lQxtSqld -lQxtWebd -lQxtWidgetsd
main.cpp
#include <QtCore> #include <QtGui> #include <QxtMailMessage> #include <QxtSmtp> #include <QtNetwork> int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); QxtMailMessage message; message.setSender("Ken31@gmail.com"); message.addRecipient("Ken31@gmail.com"); message.setSubject("Alarm"); message.setBody("Alarm message."); QxtSmtp smtp; a.connect(&smtp, SIGNAL(mailSent(int)), SLOT(quit())); smtp.setUsername("Ken31@gmail.com"); smtp.setPassword("password"); smtp.connectToSecureHost("smtp.gmail.com"); smtp.send(message); return a.exec(); }
I wanted to send an email, but it does not send, and same problem with hotmail.
-
You should add some error handling, there are several things that could go wrong.
-
testSmtp::testSmtp(QWidget *parent) : QWidget(parent) { QxtMailMessage *message =new QxtMailMessage;; message->setSender("Ken31@gmail.com"); message->addRecipient("Ken31@gmail.com"); message->setSubject("Alarm"); message->setBody("Alarm message."); QxtSmtp *smtp= new QxtSmtp(this); smtp->setUsername("Ken31@gmail.com"); smtp->setPassword("passwordGmail"); smtp->connectToSecureHost("smtp.gmail.com"); smtp->send(*message); connect(smtp, SIGNAL(mailSent(int)), this, SLOT(mailSent(int))); connect(smtp, SIGNAL(mailFailed(int,int,QByteArray)), this, SLOT(mailFailed(int,int,QByteArray))); connect(smtp, SIGNAL(recipientRejected(int,QString,QByteArray)), this, SLOT(recipientRejected(int,QString,QByteArray))); connect(smtp, SIGNAL(senderRejected(int,QString,QByteArray)), this, SLOT(senderRejected(int,QString,QByteArray))); connect(smtp, SIGNAL(connected()), this, SLOT(connected())); connect(smtp, SIGNAL(connectionFailed(QByteArray)), this, SLOT(connectionFailed(QByteArray))); connect(smtp, SIGNAL(authenticated()), this, SLOT(authenticated())); connect(smtp, SIGNAL(authenticationFailed(QByteArray)), this, SLOT(authenticationFailed(QByteArray))); connect(smtp, SIGNAL(finished()), this, SIGNAL(finished())); void testSmtp::mailSent(int mailID){ qDebug() << mailID << true; emit finished(mailID, true); } void testSmtp::mailFailed(int mailID, int, const QByteArray & msg){ emit finished(mailID, false); emit erreur(QString::number(mailID) + " mailFailed " + msg, __LINE__); } void testSmtp::recipientRejected(int mailID, const QString& address, const QByteArray & msg ){ emit erreur(QString::number(mailID) + "recipientRejected " + address + " " + msg, __LINE__); } void testSmtp::senderRejected(int mailID, const QString& address, const QByteArray & msg ){ emit erreur(QString::number(mailID) + "senderRejected " + address + " " + msg, __LINE__); } void testSmtp::connected(){ if(QCoreApplication::arguments().contains("dvp")) qDebug() << "connected"; } void testSmtp::connectionFailed( const QByteArray & msg ){ emit erreur("connectionFailed " + msg, __LINE__); finished(); } void testSmtp::authenticated(){ if(QCoreApplication::arguments().contains("dvp")) qDebug() << "authenticated"; } void testSmtp::authenticationFailed( const QByteArray & msg ){ emit erreur("authenticationFailed " + msg, __LINE__); finished(); }
testSmtp.h
class testSmtp : public QWidget { Q_OBJECT public: explicit testSmtp(QWidget *parent = 0); signals: public slots: void mailSent(int mailID); void mailFailed(int mailID, int, const QByteArray & msg); void recipientRejected(int mailID, const QString & address, const QByteArray & msg ); void senderRejected(int mailID, const QString & address, const QByteArray & msg ); void connected(); void connectionFailed( const QByteArray & msg ); void authenticated(); void authenticationFailed( const QByteArray & msg ); signals: void finished(); void finished(int id, bool result); void erreur(QString text, int no_ligne); };
i have no error . but it doesn't send