IMAP-OpenSSL - Complete sequence

This section contains user-submitted tutorials.
Post Reply
User avatar
Dravion
Senior user
Senior user
Posts: 1688
Joined: 2015-09-26 11:50
Location: Germany
Contact:

IMAP-OpenSSL - Complete sequence

Post by Dravion » 2017-06-13 13:25

Subject: Command line login via openssl, authentication , navigating in Inbox, reading messages
Requirements: Working hMailServer WAN or LAN

#Notes:
My hMailServer is working on my local testing domain imap.incubator.net.projects, but you can simply
use your local ip This tutorial uses STARTTLS, if you configured your IMAP-Server with just SSL/TLS, just remove the STARTTLS command This tutorial assumes you have a hMailServer user with name
thunderbird@incubator.net.projects with password: test123 You need OpenSSL for Windows installed - if you dont have it, you can get it from here: https://www.heise.de/download/product/w ... 6/download)

Hint:
In the following listing, you need to replace your credentials, ip addresses with your hMailServer settings.

#Listing begin
Open a non Administrator Windows Command prompt
#Clear screen
cd \ && cls

#Set your openssl.exe location to the variable OPENSSL_HOME
SET OPENSSL_HOME=C:\Users\Dravion\Documents\Visual Studio 2017\Projects\OpenSSL\version\1.1.1-dev\static\i386\release\apps
SET PATH=%PATH%;%OPENSSL_HOME%

openssl s_client -starttls imap -crlf -connect imap.incubator.net.projects:143
CONNECTED(00000188)

#If anything goes ok, you should see this line
. OK CAPABILITY completed

#Now we are connected, but not authenticated, lets login with username and password

A login thunderbird@incubator.net.projects test123

#Response should look like this
A OK LOGIN completed

#Getting your Mailinbox status
A status INBOX
* STATUS "INBOX" ()
A OK Status completed

#Now switching into the folder, in our case the inbox
A select INBOX
* 1 EXISTS
* 0 RECENT
* FLAGS (\Deleted \Seen \Draft \Answered \Flagged)
* OK [UIDVALIDITY 1495317982] current uidvalidity
* OK [UIDNEXT 10] next uid
* OK [PERMANENTFLAGS (\Deleted \Seen \Draft \Answered \Flagged)] limited

#Response should look like this
A OK [READ-WRITE] SELECT completed

#Ok, now lets read the BODY of the first Email in your inbox (not the HEADER)

. OK FETCH completed
. fetch 1 rfc822.body
* 1 FETCH (rfc822.body {1371}
Return-Path: dravion@incubator.net.projects
Delivered-To: thunderbird@incubator.net.projects
Received: from [194.241.203.202] (CAMELOT [194.241.203.202])
by smtp.incubator.net.projects with ESMTPSA
(version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128)
; Tue, 13 Jun 2017 12:52:39 +0200
Reply-To: dravion@incubator.net.projects
To: thunderbird@incubator.net.projects
From: Dravion Smith <dravion@incubator.net.projects>

>>> Here begins the content of the Email <<<

Subject: Testmail 01 for Thunderbird IMAP -INBOX
Organization: dravion@incubator.net.projects
Message-ID: <14ce96e2-8cb3-b2d4-e61d-15caab143027@incubator.net.projects>
Date: Tue, 13 Jun 2017 12:52:39 +0200
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101
Thunderbird/52.1.1
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Content-Language: en-US

Test Email for imap openssl testing
I dont attached anything.

This is the end of the body section.
)

#End of Email your email, press shortcut CTRL+X to quit to openssl session to your imap server

Post Reply