Testing Email

Mail SMTP over port 465/587


1 Aquire a copy of your username and password Base64 encoded.



echo 'user@domain.com' | base64
dXNlckBkb21haW4uY29tCg==

echo 'pass\w*rd' | base64
cGFzc1x3KnJkCg==


2 Telnet to the server



telnet smtp.ionos.co.uk 587 #Our Request causes the below lines:

Trying 217.72.192.67...
Connected to smtp.ionos.co.uk.
Escape character is '^]'.
220 kundenserver.de (mxeue111) Nemesis ESMTP Service ready


2 Or use SSL



openssl s_client -connect smtp.ionos.co.uk:465 -crlf -quiet

depth=1 C = US, O = DigiCert Inc, OU = www.digicert.com, CN = GeoTrust RSA CA 2018
verify error:num=20:unable to get local issuer certificate
verify return:0
220 kundenserver.de (mreue108) Nemesis ESMTP Service ready


3 Greet the server



EHLO mail.mcraxford.co.uk #We provide our ID
250-kundenserver.de Hello mail.mcraxford.co.uk [77.68.4.247]
250-8BITMIME
250-SIZE 157286400
250 STARTTLS


4 Tell the server that you want to login



AUTH LOGIN
334 VXNlcm5hbWU6 #Server asks for the username


5 Provide the User and Password strings from step 1



334 VXNlcm5hbWU6 #Server asks for the username
dXNlckBkb21haW4uY29tCg==
334 UGFzc3dvcmQ6 #Server asks for the password
cGFzc1x3KnJkCg==
235 Authentication succeeded #Sucess!


6 If authentication suceeeds you can send mail from your username to anyone (See the Mail Submission Guide)

IMAP Test over port 993


Telnet to the imap server



telnet imap.ionos.co.uk 143

Trying 212.227.15.138...
Connected to imap.ionos.co.uk.
Escape character is '^]'.
* OK [CAPABILITY IMAP4rev1 CHILDREN ENABLE ID IDLE LIST-EXTENDED LIST-STATUS LITERAL- MOVE NAMESPACE QUOTA SASL-IR SORT SPECIAL-USE THREAD=ORDEREDSUBJECT UIDPLUS UNSELECT WITHIN STARTTLS AUTH=LOGIN AUTH=PLAIN] IMAP server ready H mieue001 15.6 IMAP-1Mt7gP-1kYPDP32vB-00v8bp


Or Use SSL



openssl s_client -connect imap.ionos.co.uk:993 -crlf -quiet

depth=1 C = US, O = DigiCert Inc, OU = www.digicert.com, CN = GeoTrust RSA CA 2018
verify error:num=20:unable to get local issuer certificate
verify return:0
* OK [CAPABILITY IMAP4rev1 CHILDREN ENABLE ID IDLE LIST-EXTENDED LIST-STATUS LITERAL- MOVE NAMESPACE QUOTA SASL-IR SORT SPECIAL-USE THREAD=ORDEREDSUBJECT UIDPLUS UNSELECT WITHIN AUTH=LOGIN AUTH=PLAIN] IMAP server ready H mieue006 15.6 IMAP-1N7iGg-1kZn8B2JmM-0167bv


Note that this server supports SASL, AUTH=LOGIN and AUTH=PLAIN. Lets review the method for each

Requst login (SASL)

(Recommended)

First take a copy of your details with base64 encoding

echo 'user@domain.com' | base64
dXNlckBkb21haW4uY29tCg==

echo 'pass\w*rd' | base64
cGFzc1x3KnJkCg==


Then to login:

A1 authenticate login
+ VXNlcm5hbWU6
dXNlckBkb21haW4uY29tCg==
+ UGFzc3dvcmQ6
cGFzc1x3KnJkCg==
A1 OK [CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE IDLE SORT SORT=DISPLAY THREAD=REFERENCES THREAD=REFS THREAD=ORDEREDSUBJECT MULTIAPPEND URL-PARTIAL CATENATE UNSELECT CHILDREN NAMESPACE UIDPLUS LIST-EXTENDED I18NLEVEL=1 CONDSTORE QRESYNC ESEARCH ESORT SEARCHRES WITHIN CONTEXT=SEARCH LIST-STATUS BINARY MOVE NOTIFY SPECIAL-USE QUOTA] Logged in


Requst login (AUTH-PLAIN)



Take a copy of your details in a single string as follows:

echo -en "\0user@domain.com\0pass\w*rd" | base64
AHVzZXJAZG9tYWluLmNvbQBwYXNzXHcqcmQ=


Then to login:

A1 authenticate plain

AHVzZXJAZG9tYWluLmNvbQBwYXNzXHcqcmQ=
OK [CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE IDLE SORT SORT=DISPLAY THREAD=REFERENCES THREAD=REFS THREAD=ORDEREDSUBJECT MULTIAPPEND URL-PARTIAL CATENATE UNSELECT CHILDREN NAMESPACE UIDPLUS LIST-EXTENDED I18NLEVEL=1 CONDSTORE QRESYNC ESEARCH ESORT SEARCHRES WITHIN CONTEXT=SEARCH LIST-STATUS BINARY MOVE NOTIFY SPECIAL-USE QUOTA] Logged in
 


Request login (AUTH=LOGIN)



A1 login someuser@example.cloud.com My_P@ssword1
A1 OK [CAPABILITY IMAP4rev1 SASL-IR SORT
THREAD=REFERENCES MULTIAPPEND UNSELECT
LITERAL+ IDLE CHILDREN NAMESPACE LOGIN-REFERRALS
UIDPLUS LIST-EXTENDED I18NLEVEL
=1 AUTH=PLAIN] Logged in.


Check namespace



N1 namespace
* NAMESPACE (("INBOX/" "/")("virtual/" "/")) NIL NIL
n OK Namespace completed.


List folders of mailbox



L1 list "INBOX/" "*"
* LIST (HasNoChildren) "/" INBOX/some_other_folder
* LIST (HasNoChildren UnMarked Archive) "/" INBOX/Archive
* LIST (HasNoChildren UnMarked Sent) "/" INBOX/Sent
* LIST (HasNoChildren Marked Trash) "/" INBOX/Trash
* LIST (HasNoChildren Marked Junk) "/" INBOX/Spam
* LIST (HasNoChildren UnMarked Drafts) "/" INBOX/Drafts
L1 OK List completed (0.000 + 0.000 secs).


Select emails from inbox



S1 SELECT "INBOX"
* FLAGS (\Answered \Flagged \Deleted \Seen \Draft)
* OK [PERMANENTFLAGS (\Answered \Flagged \Deleted \Seen \Draft *)] Flags permitted.
* 4 EXISTS
* 0 RECENT
* OK [UNSEEN 2] First unseen.
* OK [UIDVALIDITY 1536750617] UIDs valid
* OK [UIDNEXT 9] Predicted next UID
* OK [HIGHESTMODSEQ 11] Highest
S1 OK [READ-WRITE] Select completed (0.000 + 0.000 secs).


Fetch Message Subjects



f fetch 1:(BODY[HEADER.FIELDS (Subject)])
* 1 FETCH (BODY[HEADER.FIELDS (SUBJECT){27}
Subject: Test message 1

)
* 2 FETCH (FLAGS (Seen) BODY[HEADER.FIELDS (SUBJECT){27}
Subject: Test message 3

)
* 3 FETCH (FLAGS (Seen) BODY[HEADER.FIELDS (SUBJECT){27}
Subject: Test message 5

)
* 4 FETCH (FLAGS (Seen) BODY[HEADER.FIELDS (SUBJECT){27}
Subject: Test Message 6

)
f OK Fetch completed (0.002 + 0.000 secs).


Find unseen messages



s search UNSEEN
* SEARCH 2
s OK Search completed (0.001 + 0.000 secs).


Retrieve the message

(Number 2)

F1 fetch 2 RFC822
* 2 FETCH (FLAGS (Seen) RFC822 {3009}
Return-Path: <someuser@example.cloud.com>
Delivered-To: someuser@example.cloud.com
Received: from us11-011ms.dh.cloud.com
by us11-011ms.dh.cloud.com (Dovecot) with LMTP id beGRJdw7F1xXTgAAsct0AA
for <someuser@example.cloud.com>; Mon, 17 Dec 2018 16:02:32 +1000
Received: from us11-010mrr.dh.cloud.com ([10.10.5.20])
by us11-011ms.dh.cloud.com with esmtp (Exim 4.90_1)
(envelope-from <someuser@example.cloud.com>)
id 1gYlz6-0005Df-Hx
for someuser@example.cloud.com; Mon, 17 Dec 2018 16:02:32 +1000
Received: from us11-002mrs.dh.cloud.com ([10.10.10.11])
by us11-010mrr.dh.cloud.com with esmtp (Exim 4.90_1)
(envelope-from <someuser@example.cloud.com>)
id 1gYlsn-00047x-0z
for someuser@example.cloud.com; Mon, 17 Dec 2018 15:56:01 +1000
Received: from us11-011mrc.dh.cloud.com ([10.10.3.21])
by us11-002mrs.dh.cloud.com with esmtp (Exim 4.84)
(envelope-from <someuser@example.cloud.com>)
id 1gYlvd-0007o7-7L
for someuser@example.cloud.com; Mon, 17 Dec 2018 15:58:57 +1000
Received: from us11-011wui.dh.cloud.com ([10.10.1.21] helo=localhost)
by us11-011mrc.dh.cloud.com with esmtpa (Exim 4.90_1)
(envelope-from <someuser@example.cloud.com>)
id 1gYluP-0005tV-1x
for someuser@example.cloud.com; Mon, 17 Dec 2018 15:57:41 +1000
To: <someuser@example.cloud.com>
Mime-Version: 1.0
Reply-To: "Some User" <someuser@example.cloud.com>
X-Mailer:  api 8.4.1-202
Message-Id: <cb6b04b3-b27b-41bb-b1b8-adc66e89fae6@localhost>
Date: Mon, 17 Dec 2018 15:57:12 +1000
Content-Type: multipart/alternative; boundary=5494146fa3cf177fb921d2cc0b347cd9cafaf36b1d18a797c5469f95440b
From: "Some User" <someuser@example.cloud.com>
Subject: Test message 3
X-Id: someuser@example.cloud.com
X-spam-score: 0 
X-spam-bar: / 

--5494146fa3cf177fb921d2cc0b347cd9cafaf36b1d18a797c5469f95440b
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=UTF-8

t3
--5494146fa3cf177fb921d2cc0b347cd9cafaf36b1d18a797c5469f95440b
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset=UTF-8

<div>t3</div><div><br></div><div data--signature=3D"" class=3D"gmail_=
signature" data-smartmail=3D"gmail_signature" style=3D""><br></div><div><br=
></div>
--5494146fa3cf177fb921d2cc0b347cd9cafaf36b1d18a797c5469f95440b--
)
F1 OK Fetch completed (0.002 + 0.000 secs).


Delete message number 2



d store 2 +FLAGS (\Deleted)
* 2 FETCH (FLAGS (\Deleted \Seen))
d OK Store completed (0.001 + 0.000 secs).


Expunge message number 2



e expunge
* 2 EXPUNGE
e OK Expunge completed.

Testing Emails


=====================
Test Mail from the command line
=====================

mailx -s "testo" -r from-user@example.com < email-body.txt "user@example.com" 

Mail Submission over port 25


1 Telnet to the server



telnet mx01.ionos.co.uk 25 #Our Request causes the below lines:

Trying 217.72.192.67...
Connected to mx01.ionos.co.uk.
Escape character is '^]'.
220 kundenserver.de (mxeue111) Nemesis ESMTP Service ready


2 Greet the server



EHLO mail.mcraxford.co.uk #We provide our ID
250-kundenserver.de Hello mail.mcraxford.co.uk [77.68.4.247]
250-8BITMIME
250-SIZE 157286400
250 STARTTLS


3 Tell the server who the mail is coming from and to


(the TO address must be handled/accepted by the server unless you have authenticated)

MAIL FROM:<2. SENDERADDRESS>
250 2.1.0 Ok
RCPT TO:<RECIPIENTADDRESS>
250 2.1.5 Ok


4 Tell the server we are sending DATA and provide the Subject and body then end with a period,putting a blank line between each



DATA
354 End data with <CR><LF>.<CR><LF>
Subject: Test Message

This is a test.

.
250 2.0.0 Ok: queued as 83398728027
QUIT
221 2.0.0 Bye


5 The email will be received in the recipient mailbox