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 email by SMTP
Forum Updated to NodeBB v4.3 + New Features

Send email by SMTP

Scheduled Pinned Locked Moved Unsolved General and Desktop
19 Posts 3 Posters 2.1k 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.
  • S Offline
    S Offline
    Saee1101
    wrote on last edited by
    #1
    #include "smtp.h"
    
    Smtp::Smtp( const QString &from, const QString &to, const QString &subject, const QString &body )
    {
        socket = new QTcpSocket( this );
    
        connect( socket, SIGNAL( readyRead() ), this, SLOT( readyRead() ) );
        connect( socket, SIGNAL( connected() ), this, SLOT( connected() ) )
        connect(socket, SIGNAL(stateChanged(QAbstractSocket::SocketState)), this, SLOT(stateChanged()));
            connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(errorReceived()));
        connect(socket, SIGNAL(disconnected()), this, SLOT(disconnected()));
    
    
        message = "To: " + to + "\n";
        message.append("From: " + from + "\n");
        message.append("Subject: " + subject + "\n");
        message.append(body);
        message.replace( QString::fromLatin1( "\n" ), QString::fromLatin1( "\r\n" ) );
        message.replace( QString::fromLatin1( "\r\n.\r\n" ),
        QString::fromLatin1( "\r\n..\r\n" ) );
        this->from = from;
        rcpt = to;
        state = Init;
    socket->connectToHost("smtp.gmail.com",465);
    
        if(socket->waitForConnected ( 30000 )) 	{qDebug("connected"); 	}
    
        t = new QTextStream( socket );
    }
    Smtp::~Smtp()
    {
        delete t;
        delete socket;
    }
    void Smtp::stateChanged()
    {
    
        qDebug() <<"stateChanged " ;
    }
    
    void Smtp::errorReceived()
    {
        qDebug() << "errorReceived" ;
    }
    
    void Smtp::disconnected()
    {
    
        qDebug() <<"disconneted";
        qDebug() << "error "  << socket->errorString();
    }
    
    void Smtp::connected()
    {
        output->append("connected");
        qDebug() << "Connected ";
    }
    
    void Smtp::readyRead()
    {
    
         qDebug() <<"readyRead";
        // SMTP is line-oriented
    
        QString responseLine;
        do
        {
            responseLine = socket->readLine();
            response += responseLine;
        }
        while ( socket->canReadLine() && responseLine[3] != ' ' );
    
        responseLine.truncate( 3 );
    
    
        if ( state == Init && responseLine[0] == '2' )
        {
            // banner was okay, let's go on
    
            *t << "HELO there\r\n";
            t->flush();
    
            state = Mail;
        }
        else if ( state == Mail && responseLine[0] == '2' )
        {
            // HELO response was okay (well, it has to be)
    
            *t << "MAIL FROM: " << from << "\r\n";
            t->flush();
            state = Rcpt;
        }
        else if ( state == Rcpt && responseLine[0] == '2' )
        {
    
            *t << "RCPT TO: " << rcpt << "\r\n"; //r
            t->flush();
            state = Data;
        }
        else if ( state == Data && responseLine[0] == '2' )
        {
    
            *t << "DATA\r\n";
            t->flush();
            state = Body;
        }
        else if ( state == Body && responseLine[0] == '3' )
        {
    
            *t << message << "\r\n.\r\n";
            t->flush();
            state = Quit;
        }
        else if ( state == Quit && responseLine[0] == '2' )
        {
    
            *t << "QUIT\r\n";
            t->flush();
            // here, we just close.
            state = Close;
            emit status( tr( "Message sent" ) );
        }
        else if ( state == Close )
        {
            deleteLater();
            return;
        }
        else
        {
            // something broke.
            QMessageBox::warning( 0, tr( "Qt Mail Example" ), tr( "Unexpected reply from SMTP server:\n\n" ) + response );
            state = Close;
        }
        response = "";
    }
    
    QString Smtp::base64Encode(const QString &plainText)
    {
        QByteArray textBytes = plainText.toUtf8();
         QByteArray encodedBytes = textBytes.toBase64();
         return QString(encodedBytes);
    }
    
    

    Hi, everybody. I don't know where And how get sender email password ?

    JonBJ 1 Reply Last reply
    0
    • S Saee1101
      #include "smtp.h"
      
      Smtp::Smtp( const QString &from, const QString &to, const QString &subject, const QString &body )
      {
          socket = new QTcpSocket( this );
      
          connect( socket, SIGNAL( readyRead() ), this, SLOT( readyRead() ) );
          connect( socket, SIGNAL( connected() ), this, SLOT( connected() ) )
          connect(socket, SIGNAL(stateChanged(QAbstractSocket::SocketState)), this, SLOT(stateChanged()));
              connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(errorReceived()));
          connect(socket, SIGNAL(disconnected()), this, SLOT(disconnected()));
      
      
          message = "To: " + to + "\n";
          message.append("From: " + from + "\n");
          message.append("Subject: " + subject + "\n");
          message.append(body);
          message.replace( QString::fromLatin1( "\n" ), QString::fromLatin1( "\r\n" ) );
          message.replace( QString::fromLatin1( "\r\n.\r\n" ),
          QString::fromLatin1( "\r\n..\r\n" ) );
          this->from = from;
          rcpt = to;
          state = Init;
      socket->connectToHost("smtp.gmail.com",465);
      
          if(socket->waitForConnected ( 30000 )) 	{qDebug("connected"); 	}
      
          t = new QTextStream( socket );
      }
      Smtp::~Smtp()
      {
          delete t;
          delete socket;
      }
      void Smtp::stateChanged()
      {
      
          qDebug() <<"stateChanged " ;
      }
      
      void Smtp::errorReceived()
      {
          qDebug() << "errorReceived" ;
      }
      
      void Smtp::disconnected()
      {
      
          qDebug() <<"disconneted";
          qDebug() << "error "  << socket->errorString();
      }
      
      void Smtp::connected()
      {
          output->append("connected");
          qDebug() << "Connected ";
      }
      
      void Smtp::readyRead()
      {
      
           qDebug() <<"readyRead";
          // SMTP is line-oriented
      
          QString responseLine;
          do
          {
              responseLine = socket->readLine();
              response += responseLine;
          }
          while ( socket->canReadLine() && responseLine[3] != ' ' );
      
          responseLine.truncate( 3 );
      
      
          if ( state == Init && responseLine[0] == '2' )
          {
              // banner was okay, let's go on
      
              *t << "HELO there\r\n";
              t->flush();
      
              state = Mail;
          }
          else if ( state == Mail && responseLine[0] == '2' )
          {
              // HELO response was okay (well, it has to be)
      
              *t << "MAIL FROM: " << from << "\r\n";
              t->flush();
              state = Rcpt;
          }
          else if ( state == Rcpt && responseLine[0] == '2' )
          {
      
              *t << "RCPT TO: " << rcpt << "\r\n"; //r
              t->flush();
              state = Data;
          }
          else if ( state == Data && responseLine[0] == '2' )
          {
      
              *t << "DATA\r\n";
              t->flush();
              state = Body;
          }
          else if ( state == Body && responseLine[0] == '3' )
          {
      
              *t << message << "\r\n.\r\n";
              t->flush();
              state = Quit;
          }
          else if ( state == Quit && responseLine[0] == '2' )
          {
      
              *t << "QUIT\r\n";
              t->flush();
              // here, we just close.
              state = Close;
              emit status( tr( "Message sent" ) );
          }
          else if ( state == Close )
          {
              deleteLater();
              return;
          }
          else
          {
              // something broke.
              QMessageBox::warning( 0, tr( "Qt Mail Example" ), tr( "Unexpected reply from SMTP server:\n\n" ) + response );
              state = Close;
          }
          response = "";
      }
      
      QString Smtp::base64Encode(const QString &plainText)
      {
          QByteArray textBytes = plainText.toUtf8();
           QByteArray encodedBytes = textBytes.toBase64();
           return QString(encodedBytes);
      }
      
      

      Hi, everybody. I don't know where And how get sender email password ?

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #2

      @Saee1101
      Thanks for just deleting your previous same topic after I tried to help.

      Sample code at https://github.com/bluetiger9/SmtpClient-for-Qt. Test that, then grab just the bits you want from it if you want to do it yourself/keep code small.
      You might also find https://morf.lv/simple-tls-ssl-smtp-client-for-qt5 useful.

      You will need to set up to use Qt SSL support since you are using port 465.

      I don't know what you have to do these days to connect successfully to their server (assuming you don't want to do OAuth programming). I have a feeling you need to be logged into your Google account but not sure. And you used to have to enable programmatic sending in your gmail account, don't know if that still applies. You will be providing your gmail username and password.

      V 1 Reply Last reply
      0
      • JonBJ JonB

        @Saee1101
        Thanks for just deleting your previous same topic after I tried to help.

        Sample code at https://github.com/bluetiger9/SmtpClient-for-Qt. Test that, then grab just the bits you want from it if you want to do it yourself/keep code small.
        You might also find https://morf.lv/simple-tls-ssl-smtp-client-for-qt5 useful.

        You will need to set up to use Qt SSL support since you are using port 465.

        I don't know what you have to do these days to connect successfully to their server (assuming you don't want to do OAuth programming). I have a feeling you need to be logged into your Google account but not sure. And you used to have to enable programmatic sending in your gmail account, don't know if that still applies. You will be providing your gmail username and password.

        V Offline
        V Offline
        Volker75
        wrote on last edited by
        #3

        @JonB If you want to know what you need to setup in gmail, then watch my video:
        https://www.youtube.com/watch?v=c9jdrQ8uTes

        JonBJ 1 Reply Last reply
        0
        • V Volker75

          @JonB If you want to know what you need to setup in gmail, then watch my video:
          https://www.youtube.com/watch?v=c9jdrQ8uTes

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by
          #4

          @Volker75 I don't want to know anything, I have set up in the past. The question is whether @Saee1101 needs to know anything like this....

          V 1 Reply Last reply
          0
          • JonBJ JonB

            @Volker75 I don't want to know anything, I have set up in the past. The question is whether @Saee1101 needs to know anything like this....

            V Offline
            V Offline
            Volker75
            wrote on last edited by
            #5

            @JonB
            Ah. ok. No problem.
            If (You want to know == false) { just skip reading }

            :-)

            1 Reply Last reply
            0
            • S Offline
              S Offline
              Saee1101
              wrote on last edited by
              #6

              @JonB I'm so sorry . I am confused about previous topic , thank you.
              I have gmail account and active security for access to send email .
              but I don't know get gmail password ?

              JonBJ 1 Reply Last reply
              0
              • S Saee1101

                @JonB I'm so sorry . I am confused about previous topic , thank you.
                I have gmail account and active security for access to send email .
                but I don't know get gmail password ?

                JonBJ Offline
                JonBJ Offline
                JonB
                wrote on last edited by JonB
                #7

                @Saee1101
                I don't know what you mean by "get gmail password"? To send email via Gmail SMTP you would need to send your gmail address and your password. I don't know what your password is, only you do. I am unsure whether if you are currently logged into gmail that would mean you do not need to send your username/password.

                V 1 Reply Last reply
                0
                • JonBJ JonB

                  @Saee1101
                  I don't know what you mean by "get gmail password"? To send email via Gmail SMTP you would need to send your gmail address and your password. I don't know what your password is, only you do. I am unsure whether if you are currently logged into gmail that would mean you do not need to send your username/password.

                  V Offline
                  V Offline
                  Volker75
                  wrote on last edited by
                  #8

                  @JonB No, you must NOT send your password. Watch my video. You need to create an extra password for your application. Using YOUR password doesn't work with google anymore.

                  JonBJ 1 Reply Last reply
                  1
                  • V Volker75

                    @JonB No, you must NOT send your password. Watch my video. You need to create an extra password for your application. Using YOUR password doesn't work with google anymore.

                    JonBJ Offline
                    JonBJ Offline
                    JonB
                    wrote on last edited by JonB
                    #9

                    @Volker75
                    Hi. I am sure your information is useful, and OP should try your video. I am sorry but I do not watch any videos, if your was a text/code post I would happily read it. I do now vaguely remember about creating a password at Google side, Is this all to do with https://forum.qt.io/topic/134839/gmail-smtp-authentication/17 ?

                    But in order to keep the functionality you have now, you need to enable 2FA and generate the "less secure app" credentials. That's the scope of the changes you face, if I read the situation correctly.

                    If you want to guide this OP through what he has to do at the Qt side programatically at the client (in addition to set up at Gmail side), please do so!

                    V 1 Reply Last reply
                    0
                    • JonBJ JonB

                      @Volker75
                      Hi. I am sure your information is useful, and OP should try your video. I am sorry but I do not watch any videos, if your was a text/code post I would happily read it. I do now vaguely remember about creating a password at Google side, Is this all to do with https://forum.qt.io/topic/134839/gmail-smtp-authentication/17 ?

                      But in order to keep the functionality you have now, you need to enable 2FA and generate the "less secure app" credentials. That's the scope of the changes you face, if I read the situation correctly.

                      If you want to guide this OP through what he has to do at the Qt side programatically at the client (in addition to set up at Gmail side), please do so!

                      V Offline
                      V Offline
                      Volker75
                      wrote on last edited by
                      #10

                      @JonB No problem. Yes, I am showing in the video how to create a new password and how to enable the 2FA. It is pretty hidden in the google settings. Difficult to explain with text only. You can see it in a video much better.
                      In the c++ source it is easy. I also just use that simple-mail GitHub repository. The manual there is short and easy. Enabling the 2FA on google took me the most time.

                      S 1 Reply Last reply
                      1
                      • V Volker75

                        @JonB No problem. Yes, I am showing in the video how to create a new password and how to enable the 2FA. It is pretty hidden in the google settings. Difficult to explain with text only. You can see it in a video much better.
                        In the c++ source it is easy. I also just use that simple-mail GitHub repository. The manual there is short and easy. Enabling the 2FA on google took me the most time.

                        S Offline
                        S Offline
                        Saee1101
                        wrote on last edited by Saee1101
                        #11

                        I did set password and 2FA for from@gmail.com

                        Smtp *newmail=new Smtp("from@gmail.com","to@gmail.com","Test","Hi,I'm QtCreator");
                        

                        I'm sure enter password for "from@gmail.com" . but I don't know how do it ?

                        V 1 Reply Last reply
                        0
                        • S Saee1101

                          I did set password and 2FA for from@gmail.com

                          Smtp *newmail=new Smtp("from@gmail.com","to@gmail.com","Test","Hi,I'm QtCreator");
                          

                          I'm sure enter password for "from@gmail.com" . but I don't know how do it ?

                          V Offline
                          V Offline
                          Volker75
                          wrote on last edited by Volker75
                          #12

                          @Saee1101 Just by

                          newmail.setPassword(password);
                          
                          S 1 Reply Last reply
                          0
                          • V Volker75

                            @Saee1101 Just by

                            newmail.setPassword(password);
                            
                            S Offline
                            S Offline
                            Saee1101
                            wrote on last edited by
                            #13

                            @Volker75

                            #ifndef SMTP_H
                            #define SMTP_H
                            
                            #include <QTcpSocket>
                            #include <QString>
                            #include <QTextStream>
                            #include <QDebug>
                            #include <QMessageBox>
                            #include <QTextEdit>
                            
                            class Smtp : public QObject
                            {
                                Q_OBJECT
                            
                            
                            public:
                                Smtp( const QString &from, const QString &to,
                                const QString &subject, const QString &body );
                                ~Smtp();
                            QString base64Encode(const QString &plainText);
                            signals:
                                void status( const QString &);
                            
                            public slots:
                                void stateChanged();
                                void errorReceived();
                                void disconnected();
                                void connected();
                                void readyRead();
                            
                            private:
                                QString message;
                                QTextStream *t;
                                QTcpSocket *socket;
                                QString from;
                                QString rcpt;
                                QString response;
                                 QTextEdit *output;
                                enum states{Rcpt,Mail,Data,Init,Body,Quit,Close};
                                int state;
                            
                            };
                            #endif
                            
                            

                            do you see setPassword ?!

                            V 1 Reply Last reply
                            0
                            • S Saee1101

                              @Volker75

                              #ifndef SMTP_H
                              #define SMTP_H
                              
                              #include <QTcpSocket>
                              #include <QString>
                              #include <QTextStream>
                              #include <QDebug>
                              #include <QMessageBox>
                              #include <QTextEdit>
                              
                              class Smtp : public QObject
                              {
                                  Q_OBJECT
                              
                              
                              public:
                                  Smtp( const QString &from, const QString &to,
                                  const QString &subject, const QString &body );
                                  ~Smtp();
                              QString base64Encode(const QString &plainText);
                              signals:
                                  void status( const QString &);
                              
                              public slots:
                                  void stateChanged();
                                  void errorReceived();
                                  void disconnected();
                                  void connected();
                                  void readyRead();
                              
                              private:
                                  QString message;
                                  QTextStream *t;
                                  QTcpSocket *socket;
                                  QString from;
                                  QString rcpt;
                                  QString response;
                                   QTextEdit *output;
                                  enum states{Rcpt,Mail,Data,Init,Body,Quit,Close};
                                  int state;
                              
                              };
                              #endif
                              
                              

                              do you see setPassword ?!

                              V Offline
                              V Offline
                              Volker75
                              wrote on last edited by
                              #14

                              @Saee1101 Well, you should
                              #include "../../src/SmtpMime"

                              Did you saw the "demo" folder? Check out demo4.cpp and do it exactly like that.

                              S 1 Reply Last reply
                              0
                              • S Offline
                                S Offline
                                Saee1101
                                wrote on last edited by
                                #15
                                This post is deleted!
                                1 Reply Last reply
                                0
                                • V Volker75

                                  @Saee1101 Well, you should
                                  #include "../../src/SmtpMime"

                                  Did you saw the "demo" folder? Check out demo4.cpp and do it exactly like that.

                                  S Offline
                                  S Offline
                                  Saee1101
                                  wrote on last edited by Saee1101
                                  #16

                                  @Volker75
                                  I do Enable POP for all mail or Enable POP for mail that arrives from now on. Screenshot 1.png
                                  Application Output :

                                  host : "smtp.gmail.com"
                                  port : 587
                                  ssl : false
                                  auth : false
                                  user : "test.tivanex@gmail.com"
                                  password : "nkjs **** **** ****"
                                  [SmtpClient] State: ConnectingState
                                  [Socket] State: QAbstractSocket::HostLookupState
                                  [Socket] State: QAbstractSocket::ConnectingState
                                  [Socket] State: QAbstractSocket::ConnectedState
                                  [SmtpClient] State: ConnectedState
                                  [Socket] IN:  "220 smtp.gmail.com ESMTP ti10-20020a170907c20a00b00a360ba43173sm370123ejc.99 - gsmtp\r\n"
                                  [SmtpClient] State: _EHLO_State
                                  [Socket] OUT: "EHLO localhost"
                                  [Socket] IN:  "250-smtp.gmail.com at your service, [109.125.166.7]\r\n"
                                  [Socket] IN:  "250-SIZE 35882577\r\n"
                                  [Socket] IN:  "250-8BITMIME\r\n"
                                  [Socket] IN:  "250-STARTTLS\r\n"
                                  [Socket] IN:  "250-ENHANCEDSTATUSCODES\r\n"
                                  [Socket] IN:  "250-PIPELINING\r\n"
                                  [Socket] IN:  "250-CHUNKING\r\n"
                                  [Socket] IN:  "250 SMTPUTF8\r\n"
                                  [SmtpClient] State: _READY_Connected
                                  [SmtpClient] State: ReadyState
                                  [SmtpClient] State: MailSendingState
                                  [SmtpClient] State: _MAIL_0_FROM
                                  [Socket] OUT: "MAIL FROM:<test.tivanex@gmail.com>"
                                  [Socket] IN:  "530-5.7.0 Must issue a STARTTLS command first. For more information, go to\r\n"
                                  [Socket] IN:  "530-5.7.0  https://support.google.com/a/answer/3221692 and review RFC 3207\r\n"
                                  [Socket] IN:  "530 5.7.0 specifications. ti10-20020a170907c20a00b00a360ba43173sm370123ejc.99 - gsmtp\r\n"
                                  QWindowsWindow::setGeometry: Unable to set geometry 120x30+805+451 (frame: 136x69+797+420) on QWidgetWindow/"QErrorMessageClassWindow" on "\\.\DISPLAY1". Resulting geometry: 203x124+805+451 (frame: 219x163+797+420) margins: 8, 31, 8, 8 minimum size: 203x124 MINMAXINFO maxSize=0,0 maxpos=0,0 mintrack=219,163 maxtrack=0,0)
                                  

                                  Help me ,please
                                  Help me ,please
                                  Help me ,please

                                  JonBJ 1 Reply Last reply
                                  0
                                  • S Saee1101

                                    @Volker75
                                    I do Enable POP for all mail or Enable POP for mail that arrives from now on. Screenshot 1.png
                                    Application Output :

                                    host : "smtp.gmail.com"
                                    port : 587
                                    ssl : false
                                    auth : false
                                    user : "test.tivanex@gmail.com"
                                    password : "nkjs **** **** ****"
                                    [SmtpClient] State: ConnectingState
                                    [Socket] State: QAbstractSocket::HostLookupState
                                    [Socket] State: QAbstractSocket::ConnectingState
                                    [Socket] State: QAbstractSocket::ConnectedState
                                    [SmtpClient] State: ConnectedState
                                    [Socket] IN:  "220 smtp.gmail.com ESMTP ti10-20020a170907c20a00b00a360ba43173sm370123ejc.99 - gsmtp\r\n"
                                    [SmtpClient] State: _EHLO_State
                                    [Socket] OUT: "EHLO localhost"
                                    [Socket] IN:  "250-smtp.gmail.com at your service, [109.125.166.7]\r\n"
                                    [Socket] IN:  "250-SIZE 35882577\r\n"
                                    [Socket] IN:  "250-8BITMIME\r\n"
                                    [Socket] IN:  "250-STARTTLS\r\n"
                                    [Socket] IN:  "250-ENHANCEDSTATUSCODES\r\n"
                                    [Socket] IN:  "250-PIPELINING\r\n"
                                    [Socket] IN:  "250-CHUNKING\r\n"
                                    [Socket] IN:  "250 SMTPUTF8\r\n"
                                    [SmtpClient] State: _READY_Connected
                                    [SmtpClient] State: ReadyState
                                    [SmtpClient] State: MailSendingState
                                    [SmtpClient] State: _MAIL_0_FROM
                                    [Socket] OUT: "MAIL FROM:<test.tivanex@gmail.com>"
                                    [Socket] IN:  "530-5.7.0 Must issue a STARTTLS command first. For more information, go to\r\n"
                                    [Socket] IN:  "530-5.7.0  https://support.google.com/a/answer/3221692 and review RFC 3207\r\n"
                                    [Socket] IN:  "530 5.7.0 specifications. ti10-20020a170907c20a00b00a360ba43173sm370123ejc.99 - gsmtp\r\n"
                                    QWindowsWindow::setGeometry: Unable to set geometry 120x30+805+451 (frame: 136x69+797+420) on QWidgetWindow/"QErrorMessageClassWindow" on "\\.\DISPLAY1". Resulting geometry: 203x124+805+451 (frame: 219x163+797+420) margins: 8, 31, 8, 8 minimum size: 203x124 MINMAXINFO maxSize=0,0 maxpos=0,0 mintrack=219,163 maxtrack=0,0)
                                    

                                    Help me ,please
                                    Help me ,please
                                    Help me ,please

                                    JonBJ Offline
                                    JonBJ Offline
                                    JonB
                                    wrote on last edited by
                                    #17

                                    @Saee1101 said in Send email by SMTP:

                                    Help me ,please
                                    Help me ,please
                                    Help me ,please

                                    ?

                                    Have you acted on what the output error message tells you that you need to do, to send mail via this server?

                                    S 1 Reply Last reply
                                    0
                                    • JonBJ JonB

                                      @Saee1101 said in Send email by SMTP:

                                      Help me ,please
                                      Help me ,please
                                      Help me ,please

                                      ?

                                      Have you acted on what the output error message tells you that you need to do, to send mail via this server?

                                      S Offline
                                      S Offline
                                      Saee1101
                                      wrote on last edited by
                                      #18

                                      @JonB
                                      NO , I don't know what to do , actually ?

                                      JonBJ 1 Reply Last reply
                                      0
                                      • S Saee1101

                                        @JonB
                                        NO , I don't know what to do , actually ?

                                        JonBJ Offline
                                        JonBJ Offline
                                        JonB
                                        wrote on last edited by
                                        #19

                                        @Saee1101

                                        530-5.7.0 Must issue a STARTTLS command first.

                                        The server is telling you that you are trying to send a message unencrypted, but it requires encryption and won't just send in plain text. You can see from earlier that one of the commands it accepts is STARTTLS, and you need to issue that from your client.

                                        I can't recall the details, you may wait for other responses. But I think after you send the initial EHLO greeting you then send a STARTTLS. And then I think you have to set up to use SSL socket. An example is at https://stackoverflow.com/questions/34215231/send-email-with-starttls, it's for Java but you get the idea. I'm sure you can get a better one by Googling for smtp starttls example, e.g. https://stackoverflow.com/questions/22957189/smtp-send-mail-with-qtcpsocket for Qt. If you looked at/are using https://github.com/bluetiger9/SmtpClient-for-Qt I see that mentions it has support for STARTTLS.

                                        1 Reply Last reply
                                        2

                                        • Login

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