Coder Social home page Coder Social logo

xcoder123 / simplesmtp_ssl_qt5 Goto Github PK

View Code? Open in Web Editor NEW
36.0 36.0 16.0 162 KB

A very simple implementation of SMTP protocol with SSL for Qt5

Home Page: http://morf.lv/modules.php?name=tutorials&lasit=20

License: GNU Lesser General Public License v3.0

simplesmtp_ssl_qt5's People

Contributors

xcoder123 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

simplesmtp_ssl_qt5's Issues

SOLVED: Compilation errors - wrong openssl version?

./release/smtp.o:smtp.cpp:(.text+0x50): undefined reference to _imp___ZN10QSslSocketC1EP7QObject' ./release/smtp.o:smtp.cpp:(.text+0x5cf): undefined reference to _imp___ZN10QSslSocket22connectToHostEncryptedERK7QStringt6QFlagsIN9QIODevice12OpenModeFlagEEN15QAbstractSocket20NetworkLayerProtocolE'
./release/smtp.o:smtp.cpp:(.text+0xc42): undefined reference to _imp___Zls6QDebugN15QAbstractSocket11SocketStateE' ./release/smtp.o:smtp.cpp:(.text+0xd92): undefined reference to _imp___Zls6QDebugN15QAbstractSocket11SocketErrorE'
./release/smtp.o:smtp.cpp:(.text+0x1b9b): undefined reference to _imp___ZN10QSslSocket21startClientEncryptionEv' ./release/smtp.o:smtp.cpp:(.text+0x1baa): undefined reference to _imp___ZN10QSslSocket16waitForEncryptedEi'
./release/moc_smtp.o:moc_smtp.cpp:(.text+0x1c4): undefined reference to _imp___ZN15QAbstractSocket16staticMetaObjectE' ./release/moc_smtp.o:moc_smtp.cpp:(.text+0x259): undefined reference to _imp___ZN15QAbstractSocket16staticMetaObjectE'
collect2.exe: error: ld returned 1 exit status

No Cc

Thanks for the great utility. I downloaded it and just added a simple option for Cc. Just think it would be a good addition for anyone else looking for something like this.

body text do not send

body text do not send, need to use message.append("Subject: " + subject + "\n\n");

Google now requires TLS minimum. Segfault on erroneous deleteLater() call

First off, excellent library very straight forward and I got it to work in no time! Here are a few tweaks I did have to make incase anyone else has problems.

ISSUE 1: TLS min requirements
add the following statement on line 167:

socket->setProtocol(QSsl::TlsV1_0OrLater);

socket->startClientEncryption();
if(!socket->waitForEncrypted(timeout))
{
qDebug() << socket->errorString();
state = Close;
}
................................................................
ISSUE 2: You may have to adjust your gmail account settings to allow insecure apps to login on your account. Also 2 factor auth must be disabled in order for it to work
................................................................
ISSUE 3:
On line 251 you call deleteLater() on the MainWindow object itself causing a segfault. This could also be related to the the function that looks a bit iffy in MainWindow::sendMail. At the very least its a memory leak.

Make Smtp a class member variable and use it as a stack allocated object rather than a heap allocated one. Then you wont have to worry about the dangling pointer.

Sending mail via smtp over ssl produces error message

Hi there
I am sucessfully using the Simple Smtp SSL code with QT5. It works great, the email goes through and everything seems fine, but I get the following error message:
qt.network.ssl: QSslSocket::startClientEncryption: cannot start handshake on non-plain connection

When I check, if the socket ist encrypted socket->isEncrypted() it gives a positive result.
Does this seem familiar to anyone or am I chasing ghosts unnecessarily?
Is it because we open the socket already encrypted and then the command socket->startClientEncryption() is superfluous?

Thank you all in advance!

// TERMINAL
Init STATE ------------------------------
readyRead
Server response code: "250"
Server response:  "250-smtp.mailserver.com\r\n250-SIZE 75000000\r\n250-AUTH PLAIN LOGIN\r\n250-AUTH=PLAIN LOGIN\r\n250 ENHANCEDSTATUSCODES\r\n"
Handshake STATE --------------------------
qt.network.ssl: QSslSocket::startClientEncryption: cannot start handshake on non-plain connection
is encrypted 1? ::  true
"Unknown Error"
is encrypted 2? ::  true
readyRead
Server response code: "250"
Server response:  "250-smtp.mailserver.com\r\n250-SIZE 75000000\r\n250-AUTH PLAIN LOGIN\r\n250-AUTH=PLAIN LOGIN\r\n250 ENHANCEDSTATUSCODES\r\n"
// C++
void Smtp::sendMail(){
...
 this->from = from;
    rcpt = to;
    state = Init;
    // ---- Change for SSL ---------------------------------------
    socket->connectToHostEncrypted(host, port);
...
}

void Smtp::readyRead(){
...
    else if (state == HandShake && responseLine == "250")
    {
        qDebug() << "Handshake STATE --------------------------\r";
        qDebug() << "is encrypted 1? :: " << socket->isEncrypted();
        socket->startClientEncryption();       

        if(!socket->waitForEncrypted(timeout))
        {
            qDebug() << socket->errorString();
            state = Close;
        }
        //Send EHLO once again but now encrypted
        *t << "EHLO localhost" << "\r\n";
        t->flush();

        state = Auth;
        qDebug() << "is encrypted 2? :: " << socket->isEncrypted();
    }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.