Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Send e-mail using Qt
Forum Updated to NodeBB v4.3 + New Features

Send e-mail using Qt

Scheduled Pinned Locked Moved Unsolved General and Desktop
12 Posts 3 Posters 5.2k 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.
  • O Offline
    O Offline
    ODБOï
    wrote on 15 May 2018, 10:53 last edited by
    #1

    Hello,
    Im trying to send an email to my gmail adress.

    i saw this thread : https://forum.qt.io/topic/70601/how-to-send-email-using-qt-5-5-1/10

    and i have decided to test this implementation : https://github.com/xcoder123/SimpleSmtp_SSL_QT5

    I compile and run the application but when i fill the form and click 'send' my app is not able to connect to smtp.gmail.com : 465

    stateChanged QAbstractSocket::HostLookupState
    stateChanged QAbstractSocket::ConnectingState
    stateChanged QAbstractSocket::UnconnectedState
    "Socket operation timed out"

    I don't realy know how to do now to make this work. Can someone help please ?
    Thank you

    J J 2 Replies Last reply 15 May 2018, 11:04
    0
    • O ODБOï
      15 May 2018, 10:53

      Hello,
      Im trying to send an email to my gmail adress.

      i saw this thread : https://forum.qt.io/topic/70601/how-to-send-email-using-qt-5-5-1/10

      and i have decided to test this implementation : https://github.com/xcoder123/SimpleSmtp_SSL_QT5

      I compile and run the application but when i fill the form and click 'send' my app is not able to connect to smtp.gmail.com : 465

      stateChanged QAbstractSocket::HostLookupState
      stateChanged QAbstractSocket::ConnectingState
      stateChanged QAbstractSocket::UnconnectedState
      "Socket operation timed out"

      I don't realy know how to do now to make this work. Can someone help please ?
      Thank you

      J Online
      J Online
      J.Hilk
      Moderators
      wrote on 15 May 2018, 11:04 last edited by
      #2

      @LeLev
      3 things come to my mind you can check,

      • is ssl support activated ? QSslSocket::supportsSsl()
      • are you behind a local proxy?
      • have you enabled the the less secure ssl handshake, a 4 year old repo is bound to use, in your gmail account?

      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


      Q: What's that?
      A: It's blue light.
      Q: What does it do?
      A: It turns blue.

      O 1 Reply Last reply 15 May 2018, 11:32
      3
      • O ODБOï
        15 May 2018, 10:53

        Hello,
        Im trying to send an email to my gmail adress.

        i saw this thread : https://forum.qt.io/topic/70601/how-to-send-email-using-qt-5-5-1/10

        and i have decided to test this implementation : https://github.com/xcoder123/SimpleSmtp_SSL_QT5

        I compile and run the application but when i fill the form and click 'send' my app is not able to connect to smtp.gmail.com : 465

        stateChanged QAbstractSocket::HostLookupState
        stateChanged QAbstractSocket::ConnectingState
        stateChanged QAbstractSocket::UnconnectedState
        "Socket operation timed out"

        I don't realy know how to do now to make this work. Can someone help please ?
        Thank you

        J Offline
        J Offline
        JonB
        wrote on 15 May 2018, 11:16 last edited by
        #3

        @LeLev
        For smtp.gmail.com, you need to use Port 587. Are you doing that?

        Then after the connection you should use some equivalent of (this is using a Python library, but you get the gist):

                    # upgrades the insecure server connection to a secure TLS method
                    if settings.use_tls:
                        server.starttls()
        
                    # identifies the the user to the SMTP server
                    # note: .ehlo() is used NOT .helo(), .helo() is old and insecure
                    server.ehlo()
        
                    # user login credentials are passed to server
                    server.login(settings.smtp_user, settings.smtp_password)
        
        1 Reply Last reply
        2
        • J J.Hilk
          15 May 2018, 11:04

          @LeLev
          3 things come to my mind you can check,

          • is ssl support activated ? QSslSocket::supportsSsl()
          • are you behind a local proxy?
          • have you enabled the the less secure ssl handshake, a 4 year old repo is bound to use, in your gmail account?
          O Offline
          O Offline
          ODБOï
          wrote on 15 May 2018, 11:32 last edited by
          #4

          @J.Hilk, @JonB THX.

          is ssl support activated ? QSslSocket::supportsSsl() : **YES**
          are you behind a local proxy? : **YES** (could you tell me what to do for this ?)
          have you enabled the the less secure ssl handshake, a 4 year old repo is bound to use, in your gmail account? : **YES**
          

          @JonB said in Send e-mail using Qt:

          For smtp.gmail.com, you need to use Port 587. Are you doing that?

          I tryed to use port 587

          J J 2 Replies Last reply 15 May 2018, 11:44
          0
          • O ODБOï
            15 May 2018, 11:32

            @J.Hilk, @JonB THX.

            is ssl support activated ? QSslSocket::supportsSsl() : **YES**
            are you behind a local proxy? : **YES** (could you tell me what to do for this ?)
            have you enabled the the less secure ssl handshake, a 4 year old repo is bound to use, in your gmail account? : **YES**
            

            @JonB said in Send e-mail using Qt:

            For smtp.gmail.com, you need to use Port 587. Are you doing that?

            I tryed to use port 587

            J Offline
            J Offline
            JonB
            wrote on 15 May 2018, 11:44 last edited by
            #5

            @LeLev
            Also, just to be clear (this may or may not yet affect the connection stage you are at): in GMail you have to enable a setting in your Gmail Preferences or whatever to say you want to allow SMTP, have you done that too?

            O 1 Reply Last reply 15 May 2018, 11:55
            1
            • O ODБOï
              15 May 2018, 11:32

              @J.Hilk, @JonB THX.

              is ssl support activated ? QSslSocket::supportsSsl() : **YES**
              are you behind a local proxy? : **YES** (could you tell me what to do for this ?)
              have you enabled the the less secure ssl handshake, a 4 year old repo is bound to use, in your gmail account? : **YES**
              

              @JonB said in Send e-mail using Qt:

              For smtp.gmail.com, you need to use Port 587. Are you doing that?

              I tryed to use port 587

              J Online
              J Online
              J.Hilk
              Moderators
              wrote on 15 May 2018, 11:45 last edited by J.Hilk
              #6

              @LeLev
              Sry, havn't much experience with that. You can take a look at QNetworkProxy, that in theory should provide you with everything you need.

              In the past I circumvented the issu by connecting via Mobilephone hotspot. The usecase was for me, more or less guaranteed, to be without a proxy so I did not investigate the issue further.


              Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


              Q: What's that?
              A: It's blue light.
              Q: What does it do?
              A: It turns blue.

              1 Reply Last reply
              1
              • J JonB
                15 May 2018, 11:44

                @LeLev
                Also, just to be clear (this may or may not yet affect the connection stage you are at): in GMail you have to enable a setting in your Gmail Preferences or whatever to say you want to allow SMTP, have you done that too?

                O Offline
                O Offline
                ODБOï
                wrote on 15 May 2018, 11:55 last edited by
                #7

                @JonB
                on my gmail account i only allowed less secure apps "MyAccount" > "Sign-in & security" > "Connected apps & sites" > "Allow less secure apps". I cant see option to enable/disable SMTP

                J 1 Reply Last reply 15 May 2018, 13:09
                0
                • O Offline
                  O Offline
                  ODБOï
                  wrote on 15 May 2018, 12:26 last edited by
                  #8

                  @J-Hilk I just re-checked my proxy settings and i have this :
                  Effective proxy settings
                  Use DIRECT connections.
                  Source: SYSTEM

                  1 Reply Last reply
                  0
                  • O ODБOï
                    15 May 2018, 11:55

                    @JonB
                    on my gmail account i only allowed less secure apps "MyAccount" > "Sign-in & security" > "Connected apps & sites" > "Allow less secure apps". I cant see option to enable/disable SMTP

                    J Offline
                    J Offline
                    JonB
                    wrote on 15 May 2018, 13:09 last edited by
                    #9

                    @LeLev said in Send e-mail using Qt:

                    @JonB
                    on my gmail account i only allowed less secure apps "MyAccount" > "Sign-in & security" > "Connected apps & sites" > "Allow less secure apps". I cant see option to enable/disable SMTP

                    I think you have what is necessary, I thought there was something else but it does not appear so.

                    O 1 Reply Last reply 15 May 2018, 13:43
                    0
                    • J JonB
                      15 May 2018, 13:09

                      @LeLev said in Send e-mail using Qt:

                      @JonB
                      on my gmail account i only allowed less secure apps "MyAccount" > "Sign-in & security" > "Connected apps & sites" > "Allow less secure apps". I cant see option to enable/disable SMTP

                      I think you have what is necessary, I thought there was something else but it does not appear so.

                      O Offline
                      O Offline
                      ODБOï
                      wrote on 15 May 2018, 13:43 last edited by
                      #10

                      @JonB ok thx.

                      How could i investigate to know what is wrong ?
                      As i already said, the applications compiles and run correctly but when i try to send an email i have this.. :

                      stateChanged QAbstractSocket::HostLookupState
                      stateChanged QAbstractSocket::ConnectingState
                      stateChanged QAbstractSocket::UnconnectedState
                      "Socket operation timed out"

                      I tryed to see network communication with WireShark.
                      It looks like i have no response from server :

                      myIp to 64.233.167.108 TCP 66 49485 → 587 [SYN] Seq=0 Win=8192 Len=0 MSS=1460 WS=256 SACK_PERM=1

                      myIp to 64.233.167.108 TCP 66 [TCP Retransmission] 49485 → 587 [SYN] Seq=0 Win=8192 Len=0 MSS=1460 WS=256 SACK_PERM=1

                      myIp to 64.233.167.108 TCP 62 [TCP Retransmission] 49485 → 587 [SYN] Seq=0 Win=8192 Len=0 MSS=1460 SACK_PERM=1

                      myIp to 64.233.167.109 TCP 66 49486 → 587 [SYN] Seq=0 Win=8192 Len=0 MSS=1460 WS=256 SACK_PERM=1 // i dont know why the Destination changes here ..
                      ....
                      Thx

                      J 1 Reply Last reply 15 May 2018, 14:12
                      0
                      • O ODБOï
                        15 May 2018, 13:43

                        @JonB ok thx.

                        How could i investigate to know what is wrong ?
                        As i already said, the applications compiles and run correctly but when i try to send an email i have this.. :

                        stateChanged QAbstractSocket::HostLookupState
                        stateChanged QAbstractSocket::ConnectingState
                        stateChanged QAbstractSocket::UnconnectedState
                        "Socket operation timed out"

                        I tryed to see network communication with WireShark.
                        It looks like i have no response from server :

                        myIp to 64.233.167.108 TCP 66 49485 → 587 [SYN] Seq=0 Win=8192 Len=0 MSS=1460 WS=256 SACK_PERM=1

                        myIp to 64.233.167.108 TCP 66 [TCP Retransmission] 49485 → 587 [SYN] Seq=0 Win=8192 Len=0 MSS=1460 WS=256 SACK_PERM=1

                        myIp to 64.233.167.108 TCP 62 [TCP Retransmission] 49485 → 587 [SYN] Seq=0 Win=8192 Len=0 MSS=1460 SACK_PERM=1

                        myIp to 64.233.167.109 TCP 66 49486 → 587 [SYN] Seq=0 Win=8192 Len=0 MSS=1460 WS=256 SACK_PERM=1 // i dont know why the Destination changes here ..
                        ....
                        Thx

                        J Offline
                        J Offline
                        JonB
                        wrote on 15 May 2018, 14:12 last edited by JonB
                        #11

                        @LeLev
                        I'm afraid this is a bit beyond me. But you could start by verifying you can ping there correctly. Here's mine:

                        jon@ubuntu:~$ ping smtp.gmail.com
                        PING gmail-smtp-msa.l.google.com (64.233.166.109) 56(84) bytes of data.
                        64 bytes from wm-in-f109.1e100.net (64.233.166.109): icmp_seq=1 ttl=42 time=13.5 ms
                        64 bytes from wm-in-f109.1e100.net (64.233.166.109): icmp_seq=2 ttl=42 time=12.9 ms
                        64 bytes from wm-in-f109.1e100.net (64.233.166.109): icmp_seq=3 ttl=42 time=13.3 ms
                        

                        All ...166.109 (slightly different from yours), and no retransmits...

                        O 1 Reply Last reply 15 May 2018, 14:24
                        0
                        • J JonB
                          15 May 2018, 14:12

                          @LeLev
                          I'm afraid this is a bit beyond me. But you could start by verifying you can ping there correctly. Here's mine:

                          jon@ubuntu:~$ ping smtp.gmail.com
                          PING gmail-smtp-msa.l.google.com (64.233.166.109) 56(84) bytes of data.
                          64 bytes from wm-in-f109.1e100.net (64.233.166.109): icmp_seq=1 ttl=42 time=13.5 ms
                          64 bytes from wm-in-f109.1e100.net (64.233.166.109): icmp_seq=2 ttl=42 time=12.9 ms
                          64 bytes from wm-in-f109.1e100.net (64.233.166.109): icmp_seq=3 ttl=42 time=13.3 ms
                          

                          All ...166.109 (slightly different from yours), and no retransmits...

                          O Offline
                          O Offline
                          ODБOï
                          wrote on 15 May 2018, 14:24 last edited by
                          #12

                          @JonB I also did it, it looks ok.

                          I also tested this online client, and sended an e-mail without probleme : https://www.smtper.net/
                          So i'm missing something...
                          Ok still thx.

                          1 Reply Last reply
                          0

                          1/12

                          15 May 2018, 10:53

                          • Login

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