Sending a nemail
-
Hello,
I can't find an easy way to send an email with an image with Qt5. I found out this:
http://www.developer.nokia.com/Community/Wiki/Send_a_new_email_in_Qt
But this classes was available on Qt mobility and is not available anymore. I also found out a solution with Qxt, but I am trying to lower my project dependencies.
Anyone know how I could do that?Thanks in advance,
Cédric
-
.... I',m not going to write my post which I already wrote today morning...
Qt doesn't have standard methods to send mails. use 3rd libraries like Qxt(if you trying to lower dependencies, simply copy the code of SMTP class from Qxt directly to your project. it is about 20-30 lines) or simply write your own Class, sending E-mail over the SMTP with Qt is about 10-15 lines of code... There is enough examples on the net... -
Ok so I took the Qxt classes and put it my project. I change of qt version and os very often. So that's why I lower the dependencies. For instance Qxt always worked well with me...until Qt5 was released. I couldn't compile it from the first time and didn't wanted to spend hours to search how to fixe that.
Also I tried some smtp exemples from the net. They are not always reliable. They work in easy case but not every one and then issues pop...and it's a lot of time to udnerstand how that works and why it bug.
In order to stay productive, I think taking the code of Qxt is the best thing to do. But it's not 30 lines of code but about 3000 lines spread in 12 files =) Here is a linux script to retrieve it. The variable commit contains the git revision id.
@commit=3a84efc4860740f5665594ef7d454bd2de8ccd96
wget http://dev.libqxt.org/libqxt/raw/$commit/src/core/qxtglobal.h
wget http://dev.libqxt.org/libqxt/raw/$commit/src/core/qxtglobal.cpp
wget http://dev.libqxt.org/libqxt/raw/$commit/src/core/qxthmac.h
wget http://dev.libqxt.org/libqxt/raw/$commit/src/core/qxthmac.cpp
wget http://dev.libqxt.org/libqxt/raw/$commit/src/network/qxtmailattachment.h
wget http://dev.libqxt.org/libqxt/raw/$commit/src/network/qxtmailattachment.cpp
wget http://dev.libqxt.org/libqxt/raw/$commit/src/network/qxtmailmessage.h
wget http://dev.libqxt.org/libqxt/raw/$commit/src/network/qxtmailmessage.cpp
wget http://dev.libqxt.org/libqxt/raw/$commit/src/network/qxtsmtp.h
wget http://dev.libqxt.org/libqxt/raw/$commit/src/network/qxtsmtp.cpp
wget http://dev.libqxt.org/libqxt/raw/$commit/src/network/qxtmail_p.h
wget http://dev.libqxt.org/libqxt/raw/$commit/src/network/qxtsmtp_p.h@I am curious to know why Qt doesn't have standard methods to send mails, and why they started to introduce that in qt mobility and finally removed it? Did they already say something about that?
-
I think because there is many different ways to do it on different OSs, and actually there is no standardized way for all OSs and each user can decide by itself which program he would like to use for mail synchronization... And implementing SMTP protocol with Qt is very very simple, each beginner can do that, but not every one need it directly in Qt library...
If you delete all abstraction in Qxt classes it size will decrease drastically!
P.S.: POP3 takes 35 lines of plain C code with "include" lines on windows ;) It can be even less with Qt