SimpleMailQt v2.0.0-beta1

On my last post I talked about the new async simplemail-qt API that I wanted to add, yesterday I finished the work required to have that.

SMTP (Simple Mail Transfer Protocol) as the name says it’s a very simple but strict protocol, you send a command and MUST wait for the reply, which is rather inefficient but it’s the way it is, having it async means I don’t need an extra thread (+some locking) just to send an email, no more GUI freezes or an HTTP server that is stalled.

The new Server class has a state machine that knows what reply we are waiting, and which status code is the successful one. Modern SMTP servers have PIPELING support, but it’s rather different from HTTP PIPELING, because you still have to wait for several commands before you send another command, in fact it only allows you to send the FROM the RECIPIENTS email list and DATA commands at once, parse each reply and then send the mail data, if you send the email data before you are allowed by the DATA command the server will just close the connection.

So in short we only save a few (but important) round trips, this new version also includes support for the RESET command, this is useful for example when you have a long list of emails, and some of them have malformed RECIPIENTS email, you will get an error for the command but instead of closing the connections and start the long SMTP handshake you just RESET and try to send the next email.

Cutelyst master is already using this new class if you set ViewEmail::setAsync(true);. With that set you won’t get the SMTP mail queued reply but will still be able to process more HTTP requests while waiting for the SMTP reply.

I plan to do a 2.0.0 stable release in the following weeks so if you use this library please test and suggest API changes that you may like.

Have fun!

https://github.com/cutelyst/simple-mail/releases/tag/v2.0.0-beta1

 

SimpleMailQt v2.0.0-beta1

One thought on “SimpleMailQt v2.0.0-beta1

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s