Issue with "QSslSocket" when Sending an Email
-
Hello everyone,
To start, here are the tools I'm using:QtCreator as the IDE
C++/Qt as the programming language
I'm trying to create an application that allows me to send an email with an attachment.Here’s what I’ve done so far:
My main.cpp file is configured for the basic setup and email sending.
I’ve implemented an SmtpClient class in smtpclient.h and smtpclient.cpp to handle the email-sending process, including authentication and attaching files.
However, when I run the program, I get the following messages in the console:swift
Copier
Modifier
Connecting to SMTP server: "smtp.gmail.com" on port: 465
Connected to SMTP server.
Server response: "220 smtp.gmail.com ESMTP ffacd0b85a97d-38bf322b337sm16834709f8f.59 - gsmtp\r\n"
Sending command: "EHLO Projet_test_02_Exemple_Qt"
Socket state: QAbstractSocket::ConnectedState
Raw response data: ""
Server response: "250-smtp.gmail.com at your service, [77.131.3.249]\r\n250-SIZE 35882577\r\n250-8BITMIME\r\n250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH\r\n250-ENHANCEDSTATUSCODES\r\n250-PIPELINING\r\n250 SMTPUTF8\r\n"
EHLO successful. Proceeding with authentication.
Sending command: "AUTH LOGIN"
Socket state: QAbstractSocket::ConnectedState
Raw response data: ""
Server response: "334 VXNlcm5hbWU6\r\n"
Sending command: "bS5tb3VyYWQwMTExQGdtYWlsLmNvbQ=="
Socket state: QAbstractSocket::ConnectedState
Raw response data: ""
Server response: "334 UGFzc3dvcmQ6\r\n"
Sending command: "eXpveiBxcmJ0IGxla2Egamh1dw=="
Socket state: QAbstractSocket::ConnectedState
Raw response data: ""
Server response: "235 2.7.0 Accepted\r\n"
Authentication successful. Proceeding to send email.
Sending command: "MAIL FROM:m.mourad0111@gmail.com"
Socket state: QAbstractSocket::ConnectedState
Raw response data: ""
Server response: "250 2.1.0 OK ffacd0b85a97d-38bf322b337sm16834709f8f.59 - gsmtp\r\n"
Despite this, I’m unable to successfully send the email, and no further progress is made after the MAIL FROM command.Could someone help identify what might be going wrong or how I can resolve this issue?
Thank you in advance for your help!
-
@Mourad2024 said in Issue with "QSslSocket" when Sending an Email:
Server response: "250 2.1.0 OK ffacd0b85a97d-38bf322b337sm16834709f8f.59 - gsmtp\r\n"
So far as I know
250 2.1.0 OK
indicates that "the email was delivered to the recipient server and the recipient's email address was accepted". So are you claiming it is not sent? -
@Mourad2024 said in Issue with "QSslSocket" when Sending an Email:
Sending command: "MAIL FROM
In addition to @JonB :
Not clever to leak your Gmail address...it makes the bots happy :) -
@Mourad2024 said in Issue with "QSslSocket" when Sending an Email:
Despite this, I’m unable to successfully send the email, and no further progress is made after the MAIL FROM command.
What further progress have you tried?
250 Ok
indicates the envelope sender was accepted but you appear to have not sent anything more.You should be sending one or more
RCPT TO:<alice@example.com>
lines, aDATA
line, the email headers, blank line, message body, and a line containing only a period to complete the transfer. See SMTP transport example.BTW; What does any of this have to do with the thread title?
4/4