Send email by SMTP
-
@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. -
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 ?
-
#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 ?!
-
@Volker75
I do Enable POP for all mail or Enable POP for mail that arrives from now on.
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 -
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 aSTARTTLS
. 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 forsmtp 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 forSTARTTLS
.