Unsolved Send e-mail using Qt
-
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 -
@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?
- is ssl support activated ?
-
@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)
-
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
-
@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? -
@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.
-
@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-Hilk I just re-checked my proxy settings and i have this :
Effective proxy settings
Use DIRECT connections.
Source: SYSTEM -
@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 SMTPI think you have what is necessary, I thought there was something else but it does not appear so.
-
@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 -
@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... -
@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.