Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. General talk
  3. Showcase
  4. Simple TLS/SSL supported SMTP client for Qt5

Simple TLS/SSL supported SMTP client for Qt5

Scheduled Pinned Locked Moved Showcase
32 Posts 19 Posters 42.3k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • X Offline
    X Offline
    xcoder
    wrote on 11 Jul 2013, 11:58 last edited by aha_1980
    #1

    Hi all,

    I was looking for a very simple SMTP client for Qt which would be able to support SSL/TLS and use gmail as it's smtp server.

    I found one which should have been able to do what I wanted, however I decided to improve the example SMTP client from trolltech, which was developed for Qt3.

    The original trolltech example didn't support TLS/SSL and authentification, so I added both of those and just recently I added support for multiple file attachments.

    While making the small "library" I was writing articles about how I did it and what I learned

    "Simple TLS/SSL SMTP client for Qt5":http://morf.lv/modules.php?name=tutorials&lasit=20
    "Adding file attachments to SMTP client for Qt5":http://morf.lv/modules.php?name=tutorials&lasit=21

    Hopefully it will be useful for someone else as much as for me.

    Kind Regards
    Raivis

    Only a biker knows why a dog sticks his head out of a car window.

    1 Reply Last reply
    3
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 11 Jul 2013, 13:08 last edited by
      #2

      Hi, good one !

      Thanks for sharing !

      IIRC there are several people looking for something like that

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1
      • M Offline
        M Offline
        maxvanceffer
        wrote on 12 Jul 2013, 10:08 last edited by
        #3

        Great, not so far ago i searched for library like this. And didn't found any easy, not so complicated to use. Thx, i will give it to try.

        But how about, pop3 ?

        1 Reply Last reply
        0
        • X Offline
          X Offline
          xcoder
          wrote on 12 Jul 2013, 13:25 last edited by
          #4

          POP3, is a completely different protocol, I can check it out, and maybe write a tutorial on it. So far I have only touched SMTP, which is used for sending the email not receiving.

          Glad that you guys like it.

          Only a biker knows why a dog sticks his head out of a car window.

          1 Reply Last reply
          0
          • T Offline
            T Offline
            Time Markov
            wrote on 17 Oct 2013, 22:18 last edited by
            #5

            Hi, Have someone check this tools with using some other SMTP settings (example yahoo)? With gmail it works perfectly, but when it used yahoo SMTP, there is socket timeout error?
            Thanks

            1 Reply Last reply
            0
            • X Offline
              X Offline
              xcoder
              wrote on 17 Oct 2013, 22:26 last edited by
              #6

              Hi Markov,

              Strange, I've checked with yahoo as well. Worked great for me, about 2-3 month ago.
              In any case, what settings are you using for yahoo?

              Only a biker knows why a dog sticks his head out of a car window.

              1 Reply Last reply
              0
              • T Offline
                T Offline
                Time Markov
                wrote on 18 Oct 2013, 07:12 last edited by
                #7

                Hi,
                I used these settings for yahoo SMTP:
                Mail SMTP server address: smtp.mail.yahoo.com (also with plus.smtp.mail.yahoo.com, doesn't work)
                Mail SMTP user name: Your full Yahoo! Mail email address (including "@yahoo.com")
                Mail SMTP password: Your Yahoo! Mail password
                Mail SMTP port: 465
                Mail SMTP TLS/SSL required: yes
                Thanks in advance
                Tha

                1 Reply Last reply
                0
                • M Offline
                  M Offline
                  MichelSM
                  wrote on 28 Nov 2013, 19:17 last edited by
                  #8

                  hello I used this same project in linux and it worked perfectly

                  but when I needed to use it on windows I had this error:

                  @
                  Starting C:\Users\eng-IEK\Desktop\smtp_multiple_files\build-smtp-Desktop_Qt_5_2_0_MSVC2012_64bit-Debug\debug\smtp.exe...
                  No attachments found
                  stateChanged QAbstractSocket::HostLookupState
                  stateChanged QAbstractSocket::ConnectingState
                  stateChanged QAbstractSocket::ConnectedState
                  QSslSocket: cannot call unresolved function SSLv23_client_method
                  QSslSocket: cannot call unresolved function SSL_CTX_new
                  QSslSocket: cannot call unresolved function SSL_library_init
                  QSslSocket: cannot call unresolved function ERR_get_error
                  error QAbstractSocket::SocketError( 21 )
                  QSslSocket: cannot call unresolved function ERR_get_error
                  error QAbstractSocket::SocketError( 20 )
                  Connected
                  C:\Users\eng-IEK\Desktop\smtp_multiple_files\build-smtp-Desktop_Qt_5_2_0_MSVC2012_64bit-Debug\debug\smtp.exe exited with code 0
                  @

                  anyone have any idea what it might be? maybe some lib?

                  1 Reply Last reply
                  0
                  • S Offline
                    S Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on 28 Nov 2013, 20:25 last edited by
                    #9

                    Did you install and openssl on your window machine ? Is your Qt built with SSL support ?

                    Interested in AI ? www.idiap.ch
                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                    O 1 Reply Last reply 10 Jun 2019, 08:22
                    0
                    • M Offline
                      M Offline
                      MichelSM
                      wrote on 29 Nov 2013, 11:59 last edited by
                      #10

                      I installed OpenSSL and tried again and could not anyway
                      how do I find out if my Qt is with support for SSL?

                      ALL on linux is easier kkkk

                      1 Reply Last reply
                      0
                      • S Offline
                        S Offline
                        SGaist
                        Lifetime Qt Champion
                        wrote on 29 Nov 2013, 12:48 last edited by
                        #11

                        First thing, check that you install OpenSSL 64bit to match your Qt architecture.

                        Then check that your PATH variable contains the folder of the OpenSSL libs

                        Interested in AI ? www.idiap.ch
                        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                        1 Reply Last reply
                        0
                        • M Offline
                          M Offline
                          MichelSM
                          wrote on 12 Dec 2013, 16:15 last edited by
                          #12

                          thanks for the help
                          i have installed the 32bits version, and this don't work

                          now whit the 64bits this worked

                          1 Reply Last reply
                          0
                          • Y Offline
                            Y Offline
                            yyang2000
                            wrote on 11 Mar 2014, 05:52 last edited by
                            #13

                            Hi all,

                            I am working on application using Qt4.84 and the target system is linux LTIB BSP. I want the target system can send out an email to external someone or some kind of mail box via the wifi network or wireless 3G/4G modem. I wonder if this SMTP client can solve my requirement? Since you are using Qt5, is it a problem for me to use Qt4.8.4? If you have any suggestion for the Qt4.8.4 platform, please let me know.

                            Thanks,
                            Bill

                            1 Reply Last reply
                            0
                            • G Offline
                              G Offline
                              gowikel
                              wrote on 20 Jul 2014, 23:10 last edited by
                              #14

                              Thanks, I was looking for a tutorial for do a small application than send some emails when I found this.

                              Thanks a lot

                              1 Reply Last reply
                              0
                              • P Offline
                                P Offline
                                plinioandrade
                                wrote on 12 Sept 2014, 18:59 last edited by
                                #15

                                CONGRATULATIONS TO "This Guy!!!":http://morf.lv
                                He developed the most simple and useful Qt 5 compatible SMTP Client.

                                1 Reply Last reply
                                0
                                • F Offline
                                  F Offline
                                  fab_
                                  wrote on 28 Jul 2015, 20:46 last edited by
                                  #16

                                  Hello everyone.
                                  The last post is kinda long ago so I'm hoping the someone will read this:

                                  I have an application which is required to send emails. So I setup a local mailserver and pulled bluetiger9's code here:

                                  https://github.com/bluetiger9/SmtpClient-for-Qt

                                  I was able to build a shared .dll file in release Mode. Its 120kb in size.

                                  Could someone kindly help me out now on how I can use this dll in my application?
                                  Lets say i want to use it in my application in debug Mode. It looks like it isnt enough to put the .dll file in the corresponding folder. Im not sure what extra info to include about what I've done. Please let me know

                                  1 Reply Last reply
                                  0
                                  • S Offline
                                    S Offline
                                    SGaist
                                    Lifetime Qt Champion
                                    wrote on 28 Jul 2015, 22:17 last edited by
                                    #17

                                    Hi and welcome to devnet,

                                    Do you mean compile your application to use that library or use it when deploying your application ?

                                    Interested in AI ? www.idiap.ch
                                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                    1 Reply Last reply
                                    0
                                    • F Offline
                                      F Offline
                                      fab_
                                      wrote on 29 Jul 2015, 10:15 last edited by
                                      #18

                                      Hello!

                                      It's both I guess.
                                      I want to use the functions that lib gives me in my code for my application.

                                      When i deploy the application i usually have to provide all neccessary dll files in the same folder (libmysql.dll) for example. So no static linking if thats what you're referring to.

                                      If you look at the github page of my first post. There is an example of its usage right on the front page. I'm trying to achieve to get this example to run properly.
                                      https://github.com/bluetiger9/SmtpClient-for-Qt

                                      After I made my first post I spent the rest of the night tinkering with it and I managed to get something going:

                                      Following this;
                                      https://wiki.qt.io/How_to_create_a_library_with_Qt_and_use_it_in_an_application
                                      I saw that MinGW (I use MinGW)creates a .dll and a .a file. I copied both those files in the folder containing the project where there supposed to be used. I also copied the header files in the same folder.

                                      Here is my .pro file:

                                      QT       += core
                                      QT       -= gui
                                      
                                      TARGET = SMTPEmailTestDLL
                                      CONFIG   += console
                                      CONFIG   -= app_bundle
                                      
                                      TEMPLATE = app
                                      
                                      win32:CONFIG (release, debug|release): LIBS += -L$$PWD/ -lSMTPEmail
                                      else:win32:CONFIG (debug, debug|release): LIBS += -L$$PWD/ -lSMTPEMail
                                      else:unix: LIBS += -L$$PWD/ -lSMTPEmail
                                      
                                      INCLUDEPATH += $$PWD/
                                      DEPENDPATH += $$PWD/
                                      
                                      SOURCES += main.cpp
                                      

                                      This actually enabled me to build and run the programm as seen on bluetiger9's github front page.

                                      But, upon running it either terminates with return value -1073741515 or I get the message that "The process to debug couldnt be adressed: wrong parameter"

                                      Weirdly, although receiving those messages, the programm sometimes actually sends an Email out to my gmail Account (be it with a wrong timestamp) as intended, but sometimes it just doenst.

                                      So I might've done something wrong on the way.
                                      I'm sorry if the information I'm giving is somewhat blurry. I appreciate you taking some time for this SGaist!

                                      O 1 Reply Last reply 17 Jun 2019, 03:42
                                      0
                                      • F Offline
                                        F Offline
                                        fab_
                                        wrote on 4 Aug 2015, 09:55 last edited by
                                        #19

                                        Nevermind, I got it fixed. Turns out you shouldnt rename the dll file after building it. Its name should be the same as specified in TARGET

                                        1 Reply Last reply
                                        0
                                        • D Offline
                                          D Offline
                                          DoctorD
                                          wrote on 10 Oct 2017, 12:17 last edited by
                                          #20

                                          I am using this with Qt 5.7. The email is successfuly sent but then I get this error in the end :

                                          Server response code: "221"
                                          Server response: "221 2.0.0 closing connection y144sm8277194wmd.18 - gsmtp\r\n"
                                          error QAbstractSocket::RemoteHostClosedError
                                          stateChanged QAbstractSocket::UnconnectedState
                                          disconneted
                                          error "The TLS/SSL connection has been closed"

                                          1 Reply Last reply
                                          0

                                          • Login

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • Users
                                          • Groups
                                          • Search
                                          • Get Qt Extensions
                                          • Unsolved