From c87804e7257462e92abcf1675b1030653e09f2e8 Mon Sep 17 00:00:00 2001 From: Nemo Date: Sat, 15 Aug 2020 15:14:53 +0530 Subject: [PATCH] Adds email talk --- README.md | 1 + email-protocols/cat.html | 13 + email-protocols/email-2.txt | 10 + email-protocols/email-linked.txt | 24 ++ email-protocols/email.txt | 10 + email-protocols/form-data.txt | 32 +++ email-protocols/form.html | 6 + email-protocols/index.html | 437 +++++++++++++++++++++++++++++++ email-protocols/index.md | 202 ++++++++++++++ email-protocols/test.php | 21 ++ email-protocols/u4qSjQL.jpeg | Bin 0 -> 3532 bytes 11 files changed, 756 insertions(+) create mode 100644 email-protocols/cat.html create mode 100644 email-protocols/email-2.txt create mode 100644 email-protocols/email-linked.txt create mode 100644 email-protocols/email.txt create mode 100644 email-protocols/form-data.txt create mode 100644 email-protocols/form.html create mode 100644 email-protocols/index.html create mode 100644 email-protocols/index.md create mode 100644 email-protocols/test.php create mode 100644 email-protocols/u4qSjQL.jpeg diff --git a/README.md b/README.md index 58fab47..b7bc8af 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,7 @@ Various talks & Lectures that I have given 18. [Video streaming on Linux](/talks/v4l.html). 19. [HPACK - Header Compression in HTTP/2](/talks/hpack/). 20. [Sanderson's Laws of Magic](https://docs.google.com/presentation/d/1SNEEh2_i93V64Fnzg8_05vOGjJMSuagX8IyrLt-5xXk/present) +21. [multipart-emails](/talks/email-protocols/) - A short talk on how linking with mid/cid schemes works in multipart-emails. Related work: https://github.com/awdeorio/mailmerge/issues/86 A few more talks that I've done are on my [SpeakerDeck account](https://speakerdeck.com/captn3m0) and my [slides.com](https://slides.com/captn3m0/) profile page. diff --git a/email-protocols/cat.html b/email-protocols/cat.html new file mode 100644 index 0000000..6e8332e --- /dev/null +++ b/email-protocols/cat.html @@ -0,0 +1,13 @@ + + + + Cats! + + + +
+ +
+ + + \ No newline at end of file diff --git a/email-protocols/email-2.txt b/email-protocols/email-2.txt new file mode 100644 index 0000000..d0cddc6 --- /dev/null +++ b/email-protocols/email-2.txt @@ -0,0 +1,10 @@ +From: foo1@bar.net +To: foo2@bar.net +Subject: A simple example +Content-Type: text/html; charset=utf-8 + +Hi, + +This is a cat pic: + + \ No newline at end of file diff --git a/email-protocols/email-linked.txt b/email-protocols/email-linked.txt new file mode 100644 index 0000000..50712ad --- /dev/null +++ b/email-protocols/email-linked.txt @@ -0,0 +1,24 @@ +From: foo1@bar.net +To: foo2@bar.net +Subject: A simple example +Mime-Version: 1.0 +Content-Type: multipart/related; boundary="never-graduate"; + type=Text/HTML +--never-graduate +Content-Type: Text/HTML; charset=US-ASCII + +to the other body part, for example through a statement such as: + + +--never-graduate + +Content-ID: +Content-Type: IMAGE/GIF +Content-Transfer-Encoding: BASE64 + +R0lGODlhGAGgAPEAAP/////ZRaCgoAAAACH+PUNvcHlyaWdodCAoQykgMTk5 +NSBJRVRGLiBVbmF1dGhvcml6ZWQgZHVwbGljYXRpb24gcHJvaGliaXRlZC4A +etc... + +--never-graduate-- +# remember to pitch for RFCs We Love \ No newline at end of file diff --git a/email-protocols/email.txt b/email-protocols/email.txt new file mode 100644 index 0000000..5f235c8 --- /dev/null +++ b/email-protocols/email.txt @@ -0,0 +1,10 @@ +From: foo1@bar.net +To: foo2@bar.net +Subject: A simple example +Content-Type: text/html; charset=utf-8 + +Hi, + +This is a cat pic: + + \ No newline at end of file diff --git a/email-protocols/form-data.txt b/email-protocols/form-data.txt new file mode 100644 index 0000000..c0b1f1c --- /dev/null +++ b/email-protocols/form-data.txt @@ -0,0 +1,32 @@ +POST / HTTP/1.1 +[[ Less interesting headers ... ]] +Content-Type: multipart/form-data; boundary=---------------------------boundary +Content-Length: 834 + +-----------------------------boundary +Content-Disposition: form-data; name="text1" + +text default +-----------------------------boundary +Content-Disposition: form-data; name="text2" + +aωb +-----------------------------boundary +Content-Disposition: form-data; name="file1"; filename="a.txt" +Content-Type: text/plain +Content-ID: + +Content of a.txt. + +-----------------------------boundary +Content-Disposition: form-data; name="file2"; filename="a.html" +Content-Type: text/html + +Content of a.html. + +-----------------------------boundary +Content-Disposition: form-data; name="file3"; filename="binary" +Content-Type: application/octet-stream + +aωb +-----------------------------boundary-- \ No newline at end of file diff --git a/email-protocols/form.html b/email-protocols/form.html new file mode 100644 index 0000000..0da8e7b --- /dev/null +++ b/email-protocols/form.html @@ -0,0 +1,6 @@ +
+
+ + +
+
\ No newline at end of file diff --git a/email-protocols/index.html b/email-protocols/index.html new file mode 100644 index 0000000..5188f67 --- /dev/null +++ b/email-protocols/index.html @@ -0,0 +1,437 @@ +
+

multipart-encoding in emails

+

-nemo

+
+
+

history of email RFCs

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
DateRFCTitle
Jun '73524A Proposed Mail Protocol
Sep '73561Standardizing Network Mail Headers
Apr '75680Message Transmission Protocol
May '77724Proposed Official Standard for the Format of ARPA Network Messages
Nov '77733STANDARD FOR THE FORMAT OF ARPA NETWORK TEXT MESSAGES(1)
Aug '82821SIMPLE MAIL TRANSFER PROTOCOL
Aug '82822STANDARD FOR THE FORMAT OF ARPA INTERNET TEXT MESSAGES
Jan '86974MAIL ROUTING AND THE DOMAIN SYSTEM
Apr '86983ISO Transport Services on Top of the TCP
May '871006ISO Transport Service on top of the TCP
Oct '891123Requirements for Internet Hosts -- Application and Support
Dec '891138Mapping between X.400(1988) / ISO 10021 and RFC 822
Mar '901148Mapping between X.400(1988) / ISO 10021 and RFC 822
May '921327Mapping between X.400(1988) / ISO 10021 and RFC 822
Aug '931495Mapping between X.400 and RFC-822 Message Bodies
Nov '951869SMTP Service Extensions
Mar '972111Content-ID and Message-ID Uniform Resource Locators
Jan '982156MIXER (Mime Internet X.400 Enhanced Relay): Mapping between X.400 and RFC 822/MIME
Aug '982387The MIME Multipart/Related Content-type
Aug '982392Content-ID and Message-ID Uniform Resource Locators
Apr '012821Simple Mail Transfer Protocol
Apr '012822Internet Message Format
Oct '085321Simple Mail Transfer Protocol
Oct '085322Internet Message Format
+
+
+

email protocols

+
    +
  1. how to talk to an email server (SMTP)
  2. +
+
    +
  • TCP
  • +
  • DNS
  • +
+
    +
  1. how to format a message?
  2. +
+
    +
  • Media types (MIME)
  • +
  • how to format dates?
  • +
  • html
  • +
+
    +
  1. how to receive email?
  2. +
+
    +
  • IMAP
  • +
  • POP
  • +
+
+
+

mainline

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
DateRFCTitle
Aug '82821SIMPLE MAIL TRANSFER PROTOCOL
Aug '82822STANDARD FOR THE FORMAT OF ARPA INTERNET TEXT MESSAGES
Apr '012821Simple Mail Transfer Protocol
Apr '012822Internet Message Format
Oct '085321Simple Mail Transfer Protocol
Oct '085322Internet Message Format
+
+
+

how to send emails

+ + + + + + + + + + + + + + + + + + + + + + + + + +
DateRFCTitle
Aug '82821SIMPLE MAIL TRANSFER PROTOCOL
Apr '012821Simple Mail Transfer Protocol
Oct '085321Simple Mail Transfer Protocol
+
+
+

how to write emails

+ + + + + + + + + + + + + + + + + + + + + + + + + +
DateRFCTitle
Aug '82822STANDARD FOR THE FORMAT OF ARPA INTERNET TEXT MESSAGES
Apr '012822Internet Message Format
Oct '085322Internet Message Format
+
+
+

the multipart-variation

+ + + + + + + + + + + + + + + + + + + + +
DateRFCTitle
Mar '972111Content-ID and Message-ID Uniform Resource Locators
Aug '982392Content-ID and Message-ID Uniform Resource Locators
+
+
+

what's multi-part?

+
POST / HTTP/1.1
+[[ Less interesting headers ... ]]
+Content-Type: multipart/form-data; boundary=--boundary
+Content-Length: 834
+
+--boundary
+Content-Disposition: form-data; name="text1"
+
+text default
+--boundary
+Content-Disposition: form-data; name="text2"
+
+
+
+
+
From: foo1@bar.net
+To: foo2@bar.net
+Subject: A simple example
+Mime-Version: 1.0
+Content-Type: multipart/alternate; boundary="never-graduate";
+--never-graduate
+Content-Type: Text/HTML; charset=US-ASCII
+Content-Id: <html.foo1@bar.net>
+
+This is <strong>My HTML</strong> email.
+
+--never-graduate
+
+Content-Id: <plaintext.foo1@bar.net>
+Content-Type: text/plain
+
+This is my plaintext email.
+
+--never-graduate--
+
+
+
+

multi-part-linking

+ + + + + + + + + + + + + + + + + + + + +
DateRFCTitle
Mar '972111Content-ID and Message-ID Uniform Resource Locators
Aug '982392Content-ID and Message-ID Uniform Resource Locators
+
+
+

multi-part-linking

+ + + + + + + + + + + + + + + + + +
SchemeName
cid:Content ID URL Scheme
mid:Message ID URL Scheme
+
+
+

definitions

+
content-id    = url-addr-spec
+message-id    = url-addr-spec
+
+url-addr-spec = addr-spec  ; URL encoding of RFC 822 addr-spec
+
+cid-url       = "cid" ":" content-id
+mid-url       = "mid" ":" message-id [ "/" content-id ]
+
+
+
+

plain english

+
    +
  • Content and Message IDs are emails
  • +
  • CID/MID URLs are cid:$CID, mid:$MID, and mid:$MID/$CID
  • +
+
+
+

so how does it work?

+
From: foo1@bar.net
+To: foo2@bar.net
+Subject: A simple example
+Mime-Version: 1.0
+Content-Type: multipart/related; boundary="never-graduate";type=Text/HTML
+
+--never-graduate
+Content-Type: Text/HTML; charset=US-ASCII
+
+to the other body part, for example through a statement such as:
+<img src="cid:foo4*foo1@bar.net">
+
+--never-graduate
+
+Content-ID: <foo4*foo1@bar.net>
+Content-Type: IMAGE/GIF
+Content-Transfer-Encoding: BASE64
+
+R0lGODlhGAGgAPEAAP/////ZRaCgoAAAACH+PUNvcHlyaWdodCAoQykgMTk5
+NSBJRVRGLiBVbmF1dGhvcml6ZWQgZHVwbGljYXRpb24gcHJvaGliaXRlZC4A
+etc...
+
+--never-graduate--
+# remember to pitch for RFCs We Love
+
+
+
\ No newline at end of file diff --git a/email-protocols/index.md b/email-protocols/index.md new file mode 100644 index 0000000..4325521 --- /dev/null +++ b/email-protocols/index.md @@ -0,0 +1,202 @@ +# multipart-encoding in emails +\-nemo + +--- +# history of email RFCs + +Date|RFC|Title +----|-----|----- +Jun '73|524|A Proposed Mail Protocol +Sep '73|561|Standardizing Network Mail Headers +Apr '75|680|Message Transmission Protocol +May '77|724|Proposed Official Standard for the Format of ARPA Network Messages +Nov '77|733|STANDARD FOR THE FORMAT OF ARPA NETWORK TEXT MESSAGES(1) +Aug '82|821|SIMPLE MAIL TRANSFER PROTOCOL +Aug '82|822|STANDARD FOR THE FORMAT OF ARPA INTERNET TEXT MESSAGES +Jan '86|974|MAIL ROUTING AND THE DOMAIN SYSTEM +Apr '86|983|ISO Transport Services on Top of the TCP +May '87|1006|ISO Transport Service on top of the TCP +Oct '89|1123|Requirements for Internet Hosts -- Application and Support +Dec '89|1138|Mapping between X.400(1988) / ISO 10021 and RFC 822 +Mar '90|1148|Mapping between X.400(1988) / ISO 10021 and RFC 822 +May '92|1327|Mapping between X.400(1988) / ISO 10021 and RFC 822 +Aug '93|1495|Mapping between X.400 and RFC-822 Message Bodies +Nov '95|1869|SMTP Service Extensions +Mar '97|2111|Content-ID and Message-ID Uniform Resource Locators +Jan '98|2156|MIXER (Mime Internet X.400 Enhanced Relay): Mapping between X.400 and RFC 822/MIME +Aug '98|2387|The MIME Multipart/Related Content-type +Aug '98|2392|Content-ID and Message-ID Uniform Resource Locators +Apr '01|2821|Simple Mail Transfer Protocol +Apr '01|2822|Internet Message Format +Oct '08|5321|Simple Mail Transfer Protocol +Oct '08|5322|Internet Message Format + +--- + + +# email protocols + +1. how to talk to an email server (SMTP) + - TCP + - DNS +2. how to format a message? + - Media types (MIME) + - how to format dates? + - html +3. how to receive email? + - IMAP + - POP + +--- +# mainline + +Date|RFC|Title +----|-----|----- +Aug '82|821|SIMPLE MAIL TRANSFER PROTOCOL +Aug '82|822|STANDARD FOR THE FORMAT OF ARPA INTERNET TEXT MESSAGES +Apr '01|2821|Simple Mail Transfer Protocol +Apr '01|2822|Internet Message Format +Oct '08|5321|Simple Mail Transfer Protocol +Oct '08|5322|Internet Message Format + +--- + +# how to send emails + +Date|RFC|Title +----|-----|----- +Aug '82|821|SIMPLE MAIL TRANSFER PROTOCOL +Apr '01|2821|Simple Mail Transfer Protocol +Oct '08|5321|Simple Mail Transfer Protocol + +--- + +# how to write emails + +Date|RFC|Title +----|-----|----- +Aug '82|822|STANDARD FOR THE FORMAT OF ARPA INTERNET TEXT MESSAGES +Apr '01|2822|Internet Message Format +Oct '08|5322|Internet Message Format + +--- + +# the multipart-variation + +Date|RFC|Title +----|-----|----- +Mar '97|2111|Content-ID and Message-ID Uniform Resource Locators +Aug '98|2392|Content-ID and Message-ID Uniform Resource Locators + +--- + +# what's multi-part? + +``` +POST / HTTP/1.1 +[[ Less interesting headers ... ]] +Content-Type: multipart/form-data; boundary=--boundary +Content-Length: 834 + +--boundary +Content-Disposition: form-data; name="text1" + +text default +--boundary +Content-Disposition: form-data; name="text2" + +``` + +--- + +``` +From: foo1@bar.net +To: foo2@bar.net +Subject: A simple example +Mime-Version: 1.0 +Content-Type: multipart/alternate; boundary="never-graduate"; +--never-graduate +Content-Type: Text/HTML; charset=US-ASCII +Content-Id: + +This is My HTML email. + +--never-graduate + +Content-Id: +Content-Type: text/plain + +This is my plaintext email. + +--never-graduate-- +``` + +--- + +# multi-part-linking + +Date|RFC|Title +----|-----|----- +Mar '97|2111|Content-ID and Message-ID Uniform Resource Locators +Aug '98|2392|Content-ID and Message-ID Uniform Resource Locators + +--- + +# multi-part-linking + +Scheme|Name +---|--- +`cid:`|Content ID URL Scheme +`mid:`|Message ID URL Scheme + +--- + +# definitions + +``` +content-id = url-addr-spec +message-id = url-addr-spec + +url-addr-spec = addr-spec ; URL encoding of RFC 822 addr-spec + +cid-url = "cid" ":" content-id +mid-url = "mid" ":" message-id [ "/" content-id ] +``` + +--- + +# plain english + +* Content and Message IDs are emails +* CID/MID URLs are `cid:$CID`, `mid:$MID`, and `mid:$MID/$CID` + +--- + +# so how does it work? + +``` +From: foo1@bar.net +To: foo2@bar.net +Subject: A simple example +Mime-Version: 1.0 +Content-Type: multipart/related; boundary="never-graduate";type=Text/HTML + +--never-graduate +Content-Type: Text/HTML; charset=US-ASCII + +to the other body part, for example through a statement such as: + + +--never-graduate + +Content-ID: +Content-Type: IMAGE/GIF +Content-Transfer-Encoding: BASE64 + +R0lGODlhGAGgAPEAAP/////ZRaCgoAAAACH+PUNvcHlyaWdodCAoQykgMTk5 +NSBJRVRGLiBVbmF1dGhvcml6ZWQgZHVwbGljYXRpb24gcHJvaGliaXRlZC4A +etc... + +--never-graduate-- +# remember to pitch for RFCs We Love +``` \ No newline at end of file diff --git a/email-protocols/test.php b/email-protocols/test.php new file mode 100644 index 0000000..918ab34 --- /dev/null +++ b/email-protocols/test.php @@ -0,0 +1,21 @@ + +multipart-not-supported +--never-graduate-- +Content-Type: text/html; charset=utf-8 +Content-Base: http://localhost:1111/ + + + + + + + Hello from a html + + + +--never-graduate-- \ No newline at end of file diff --git a/email-protocols/u4qSjQL.jpeg b/email-protocols/u4qSjQL.jpeg new file mode 100644 index 0000000000000000000000000000000000000000..960425e725dd57da6db4971da497401388c11105 GIT binary patch literal 3532 zcmbW!c{J2*-vIF6%-EB4hRlq@NM=yhvSzzS3|R(4NLjLzF_vgU8JR4ZGR#n67(+(c zx4R_!h%|-}?xLo$CF!Z$x;^gadC&Wv^Zxa|&-Xgl_k7Q}zTfLypL6X@?YseGaCQ!M z00;yCpxp)RyasFmIY}uQsXcNs(lStaIT%7m8KI}$R!FLW9KO#D+Z(i zgAkA!0G0(oWI;Q~!f5Y0Huy??@dw3GOyifTA1)mEE4GWJT#U~^tT}V#3c0Gffc_WKLy?v*ER#-%5 zlrt+TSyk-nnuf-v=9bpB_Ks&gy?y-ygF{^2IDcaD)ztLN+l9qpn@pbdt zKfeF?x%IaT1VH}H+Rgul{V$j7t_v(A1Q8Pb+XVtA?QV#ykg%$rh@7>XXaG@OO+QTx zYLj19-z|p-zVgJhvR3?5y92b<&J$xxmqSVxt7=>eT{VOAX1n+OERm=rvVC(EykD?iSQe0871m=> zD6Ynpl`0iarMksj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