PDA

View Full Version : send an email from my Qt application



omega36
19th December 2008, 20:04
hy,
I need to send an email from my Qt application, but but I don't know where to begin :confused:

I use WinXP with Qt4.2.2 ( Visual Studio 2005 C++ )

thanks

ktk
19th December 2008, 20:08
hy,
I need to send an email from my Qt application, but but I don't know where to begin :confused:

I use WinXP with Qt4.2.2 ( Visual Studio 2005 C++ )

thanks

QTcpSocket, and "SMTP" (Simple Mail Transfer Protocol)

SMTP server often listen on port 25...

tpf80
19th December 2008, 22:58
See this post: http://www.qtcentre.org/forum/f-qt-programming-2/t-sending-email-using-qt-2221.html

omega36
20th December 2008, 10:46
thanks I try with this :)

omega36
20th December 2008, 11:07
I come not to compile the exemple,
I Have a problem in the file " qthread_p.h",
#include "qplatformdefs.h" not found

yonnak
20th December 2008, 11:49
Hello,
I wrote this class ( with other people ) wich works well
Here is the link: http://forum.qtfr.org/attachment.php?item=228

yonnak
20th December 2008, 11:59
Sorry wrong link
the good one: http://forum.qtfr.org/attachment.php?item=200

omega36
20th December 2008, 12:10
in this exemple , you use Qt4.3,
I work with Qt4.2.2 so I dont have "QAuthenticator" includ :(


I m right ?

yonnak
20th December 2008, 12:23
Yes you are right. Authenticator is used for proxy authentification.
As far as I know, noone as never try this class with a proxy ( I don't).
This is a very particular case so I think you can comment sections about authenticator and get the class to compile.

omega36
20th December 2008, 12:49
ok I did wath you say, and now I have the same problem with an other includ :(
#include <QSslSocket>

( and may be others includ of Qt4.3 )

ideas ?

yonnak
20th December 2008, 13:17
Yes,
The QSslSocket aims at support ssl with SMTP
You've got two options: recompile Qt with openssl support or delete everything about QSslSocket and use only QTcpSocket. In this case you cannot connect to SMTP servers that required SSL.

As before, this a particular case and most SMTP servers accept non encrypted connections. I think this as nothing to do with Qt 4.3, I'm quite sure you can compile Qt with SSL

yagabey
21st December 2008, 14:29
Alternatively, see that application:

http://www.qt-apps.org/content/show.php/Pop3Retriever?content=91315

d_stranz
22nd December 2008, 03:47
If all you want to do is -send- an e-mail from your application, it is very easy to use QDesktopServices:



QString strMailTo( "mailto:someone@someAddress.com?subject='My E-mail example'&body=" );
strMailTo += "Hi! This is the body of the e-mail";
bool bResult = QDesktopServices::openUrl( QUrl( strMailTo ) );


The QUrl constructor will convert the "strMailTo" string into a proper URL (that is, replace spaces by %20%, and so forth). The Boolean result tells you whether the call succeeded or not.

Forget all this stuff about sockets, TCP, SMTP, and so on.

David

omega36
22nd December 2008, 11:06
very thanks to all,

Yes,
The QSslSocket aims at support ssl with SMTP
You've got two options: recompile Qt with openssl support or delete everything about QSslSocket and use only QTcpSocket. In this case you cannot connect to SMTP servers that required SSL.

As before, this a particular case and most SMTP servers accept non encrypted connections. I think this as nothing to do with Qt 4.3, I'm quite sure you can compile Qt with SSL

Ok I wil see for the second option :)


If all you want to do is -send- an e-mail from your application, it is very easy to use QDesktopServices:




QString strMailTo( "mailto:someone@someAddress.com?subject='My E-mail example'&body=" );
strMailTo += "Hi! This is the body of the e-mail";
bool bResult = QDesktopServices::openUrl( QUrl( strMailTo ) );


I need to send an attach file .

omega36
22nd December 2008, 18:06
:confused: :(
NoBody!