Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Channelmiddle/79dcf595c085fee928635063affb2215 to your computer and use it in GitHub Desktop.
Save Channelmiddle/79dcf595c085fee928635063affb2215 to your computer and use it in GitHub Desktop.
# Example encoding of an email message in JSON
{
headers: [ # in an array since order matters
{ name: 'Subject', value: 'An email' },
{ name: 'Date', value: 'Thu, 4 Mar 2010 15:35:32 -0800' },
{ name: 'From', value: 'george@foo.com' },
{ name: 'To', value: 'paul@goo.com' }
{ name: 'Sender', value: 'paul@goo.com' }
{ name: 'Reply-to', value: 'paul@goo.com' }
],
from: 'From blah blah...',
body: {
type: 'multipart/alternative,
parts: [
{
id: 'partid-1',
type: 'text/plain',
sections: [
{
type: 'greeting',
text: 'Dear Jason,'
},
{
type: 'normal',
text: ["This is an ", {type: 'url', href: 'http://foo.com, text: "URL"}, ", that I have embedded in some text."]
},
{
type: quoted-section,
text: "Something worth quoting."
},
{
type: quoted-section,
body: {
headers: [
{ name: 'Subject', value: 'Hey there' },
{ name: 'Date', ... }
],
body: {
type: 'text/plain',
text: 'Hi there'
}
}
},
{
type: 'signature',
text: '...'
}
]
},
{
id: 'id',
type: 'text/html'
text: '<bold>Dear Jason</bold>, <br/>This is a test.',
},
]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment