Reputation: 1623
What is the minimum size in bytes of a valid email (not programming language specific)
Upvotes: 0
Views: 1779
Reputation: 1623
So I just went through a tutorial to answer part of this question about the format / structure of a basic email. I started with the following command
$ nc -C {smtp-server-fqdn} 25
Here is a dump of the conversation {parametrized with secrets omitted}
220 {smtp-server-fqdn} ESMTP
EHLO {yourdomain.ext}
{smtp-server-fqdn}
250-PIPELINING
250-SIZE 40960000
250-ETRN
250-STARTTLS
250-AUTH PLAIN LOGIN
250-AUTH=PLAIN LOGIN
250-ENHANCEDSTATUSCODES
250 8BITMIME
HELO {yourdomain.ext}
250 {smtp-server-fqdn}
AUTH LOGIN
334 VXNlcm5hbWU6
{username|base64}
334 UGFzc3dvcmQ6
{password|base64}
235 2.7.0 Authentication successful
MAIL FROM: <someone@sender-fqdn>
250 2.1.0 Ok
RCPT TO: <someone@recipient-fqdn>
250 2.1.5 Ok
DATA
354 End data with <CR><LF>.<CR><LF>
From: "{VanitySenderName}" <someone@sender-fqdn>
To: "{VanityRecipientName}" <someone@recipient-fqdn>
Subject: {subject}
Date: {date}
{message body}
.
250 2.0.0 Ok: queued as {identifier}
QUIT
221 2.0.0 Bye
<ctrl>+<c>
So to break this down
Email payload itself (following line after DATA
until .
) takes a minimum of 75 bytes
From: <a@b>
To: <a@b>
Subject: c
Date: Sat, 20 Apr 2019 13:25:00 +0100
d
.
Honestly this is barely a valid email. It does have two additional fields to the minimum as per https://www.rfc-editor.org/rfc/rfc5322#page-21 It's a from, to, subject, date and body. If any of these were missing, I think your email provider should reject them.
The actual body I sent to test this with my real email and a provider (dreamhost) was 151 bytes because the emails were real and the domain was longer than a character.
More interestingly the envelope took this to 468 bytes (for the real email with auth not including server responses), but theoretically could be smaller (146 bytes with single character domain with no extension, only good for lab + internal)
EHLO c
HELO c
AUTH LOGIN
a
b
MAIL FROM: <a@b>
RCPT TO: <a@b>
DATA
From: <a@b>
To: <a@b>
Subject: c
Date: Sat, 20 Apr 2019 13:25:00 +0100
d
.
QUIT
It's < 1KB so fit for embedded, but is also missing transport overhead, and missing several features, such as multi-part support.
All you'd need to do to use this is equip yourself with a socket library to open the connection, base64 encoder (for plain user + password), a date string generation utility and rudimentary command-line skills.
This is by no means a complete answer, but it answers two of the cases with necessary caveats for the understanding of a beginner, getting to grips with the technology.
Upvotes: 2
Reputation: 9685
This doesn't seem to be a a programming question, right? Might want to clarify, or it'll be closed.
Tens of bytes in each case. 40-45 bytes for the minimal valid message, closer to 100 with an attachment. Some depend on how you're counting, e.g. when the message is 50 bytes, whether you include the bytes for the IMAP/POP login process matters a great deal.
Date: 0:00:00 1 May 2019 -0000
From: [email protected]
Upvotes: 0