blob: 6e2153cbd79572db8e601cf4ebaba62e7dff1a74 [file] [log] [blame]
Dusan Kasan17e497e2017-04-10 22:44:22 +02001package parsemail_test
2
3import (
4 "testing"
5 "github.com/DusanKasan/parsemail"
6 "strings"
7 "time"
8 "net/mail"
9 "encoding/base64"
10 "io/ioutil"
11)
12
13func TestParseEmail(t *testing.T) {
Dusan Kasanb49ceb62017-04-13 00:00:36 +020014 var testData = map[int]struct{
Dusan Kasan17e497e2017-04-10 22:44:22 +020015 mailData string
16
17 subject string
Dusan Kasanb49ceb62017-04-13 00:00:36 +020018 date time.Time
19 from []mail.Address
20 sender mail.Address
21 to []mail.Address
22 replyTo []mail.Address
23 cc []mail.Address
24 bcc []mail.Address
Dusan Kasan17e497e2017-04-10 22:44:22 +020025 messageID string
Dusan Kasanb49ceb62017-04-13 00:00:36 +020026 resentDate time.Time
27 resentFrom []mail.Address
28 resentSender mail.Address
29 resentTo []mail.Address
30 resentReplyTo []mail.Address
31 resentCc []mail.Address
32 resentBcc []mail.Address
33 resentMessageID string
Dusan Kasan17e497e2017-04-10 22:44:22 +020034 inReplyTo []string
35 references []string
Dusan Kasan17e497e2017-04-10 22:44:22 +020036 htmlBody string
37 textBody string
38 attachments []attachmentData
39 embeddedFiles []embeddedFileData
40 headerCheck func (mail.Header, *testing.T)
41 }{
Dusan Kasanb49ceb62017-04-13 00:00:36 +020042 1: {
43 mailData: RFC5322_Example_A11,
44 subject: "Saying Hello",
45 from: []mail.Address{
46 {"John Doe", "jdoe@machine.example"},
47 },
48 to: []mail.Address{
49 {"Mary Smith", "mary@example.net"},
50 },
51 sender: mail.Address{"Michael Jones", "mjones@machine.example"},
52 messageID: "1234@local.machine.example",
53 date: parseDate("Fri, 21 Nov 1997 09:55:06 -0600"),
54 textBody: `This is a message just to say hello.
55So, "Hello".`,
56 },
57 2: {
58 mailData: RFC5322_Example_A12,
59 from: []mail.Address{
60 {"Joe Q. Public", "john.q.public@example.com"},
61 },
62 to: []mail.Address{
63 {"Mary Smith", "mary@x.test"},
64 {"", "jdoe@example.org"},
65 {"Who?", "one@y.test"},
66 },
67 cc: []mail.Address{
68 {"", "boss@nil.test"},
69 {"Giant; \"Big\" Box", "sysservices@example.net"},
70 },
71 messageID: "5678.21-Nov-1997@example.com",
72 date: parseDate("Tue, 01 Jul 2003 10:52:37 +0200"),
73 textBody: `Hi everyone.`,
74 },
75 3: {
76 mailData: RFC5322_Example_A2a,
77 subject: "Re: Saying Hello",
78 from: []mail.Address{
79 {"Mary Smith", "mary@example.net"},
80 },
81 replyTo: []mail.Address{
82 {"Mary Smith: Personal Account", "smith@home.example"},
83 },
84 to: []mail.Address{
85 {"John Doe", "jdoe@machine.example"},
86 },
87 messageID: "3456@example.net",
88 inReplyTo: []string{"1234@local.machine.example"},
89 references: []string{"1234@local.machine.example"},
90 date: parseDate("Fri, 21 Nov 1997 10:01:10 -0600"),
91 textBody: `This is a reply to your hello.`,
92 },
93 4: {
94 mailData: RFC5322_Example_A2b,
95 subject: "Re: Saying Hello",
96 from: []mail.Address{
97 {"John Doe", "jdoe@machine.example"},
98 },
99 to: []mail.Address{
100 {"Mary Smith: Personal Account", "smith@home.example"},
101 },
102 messageID: "abcd.1234@local.machine.test",
103 inReplyTo: []string{"3456@example.net"},
104 references: []string{"1234@local.machine.example", "3456@example.net"},
105 date: parseDate("Fri, 21 Nov 1997 11:00:00 -0600"),
106 textBody: `This is a reply to your reply.`,
107 },
108 5: {
109 mailData: RFC5322_Example_A3,
110 subject: "Saying Hello",
111 from: []mail.Address{
112 {"John Doe", "jdoe@machine.example"},
113 },
114 to: []mail.Address{
115 {"Mary Smith", "mary@example.net"},
116 },
117 messageID: "1234@local.machine.example",
118 date: parseDate("Fri, 21 Nov 1997 09:55:06 -0600"),
119 resentFrom: []mail.Address{
120 {"Mary Smith", "mary@example.net"},
121 },
122 resentTo: []mail.Address{
123 {"Jane Brown", "j-brown@other.example"},
124 },
125 resentMessageID: "78910@example.net",
126 resentDate: parseDate("Mon, 24 Nov 1997 14:22:01 -0800"),
127 textBody: `This is a message just to say hello.
128So, "Hello".`,
129 },
130 6: {
Dusan Kasan17e497e2017-04-10 22:44:22 +0200131 mailData: Data1,
132 subject: "Test Subject 1",
Dusan Kasanb49ceb62017-04-13 00:00:36 +0200133 from: []mail.Address{
134 {"Peter Paholík", "peter.paholik@gmail.com"},
135 },
136 to: []mail.Address{
137 {"", "dusan@kasan.sk"},
138 },
Dusan Kasan17e497e2017-04-10 22:44:22 +0200139 messageID: "CACtgX4kNXE7T5XKSKeH_zEcfUUmf2vXVASxYjaaK9cCn-3zb_g@mail.gmail.com",
140 date: parseDate("Fri, 07 Apr 2017 09:17:26 +0200"),
141 htmlBody: "<div dir=\"ltr\"><br></div>",
142 attachments: []attachmentData{
143 {
144 filename: "Peter Paholík 1 4 2017 2017-04-07.pdf",
Dusan Kasanb49ceb62017-04-13 00:00:36 +0200145 contentType: "application/pdf",
Dusan Kasan17e497e2017-04-10 22:44:22 +0200146 base64data: "JVBERi0xLjQNCiW1tbW1DQoxIDAgb2JqDQo8PC9UeXBlL0NhdGFsb2cvUGFnZXMgMiAwIFIvTGFuZyhlbi1VUykgL1N0cnVjdFRyZWVSb290IDY3IDAgUi9NYXJrSW5mbzw8L01hcmtlZCB0cnVlPj4vT3V0cHV0SW50ZW50c1s8PC9UeXBlL091dHB1dEludGVudC9TL0dUU19QREZBMS9PdXRwdXRDb25kZXYgMzk1MzYyDQo+Pg0Kc3RhcnR4cmVmDQo0MTk4ODUNCiUlRU9GDQo=",
147 },
148 },
149 },
Dusan Kasanb49ceb62017-04-13 00:00:36 +0200150 7: {
Dusan Kasan17e497e2017-04-10 22:44:22 +0200151 mailData: Data2,
152 subject: "Re: Test Subject 2",
Dusan Kasanb49ceb62017-04-13 00:00:36 +0200153 from: []mail.Address{
154 {"Sender Man", "sender@domain.com"},
155 },
156 to: []mail.Address{
157 {"", "info@receiver.com"},
158 },
159 cc: []mail.Address{
160 {"Cc Man", "ccman@gmail.com"},
161 },
Dusan Kasan17e497e2017-04-10 22:44:22 +0200162 messageID: "0e9a21b4-01dc-e5c1-dcd6-58ce5aa61f4f@receiver.com",
163 inReplyTo: []string{"9ff38d03-c4ab-89b7-9328-e99d5e24e3ba@receiver.eu"},
164 references: []string{"2f6b7595-c01e-46e5-42bc-f263e1c4282d@receiver.com", "9ff38d03-c4ab-89b7-9328-e99d5e24e3ba@domain.com"},
165 date: parseDate("Fri, 07 Apr 2017 12:59:55 +0200"),
166 htmlBody: `<html>data<img src="part2.9599C449.04E5EC81@develhell.com"/></html>`,
167 textBody: `First level
168> Second level
169>> Third level
170>
171`,
172 embeddedFiles: []embeddedFileData{
173 {
174 cid: "part2.9599C449.04E5EC81@develhell.com",
Dusan Kasanb49ceb62017-04-13 00:00:36 +0200175 contentType: "image/png",
Dusan Kasan17e497e2017-04-10 22:44:22 +0200176 base64data: "iVBORw0KGgoAAAANSUhEUgAAAQEAAAAYCAIAAAB1IN9NAAAACXBIWXMAAAsTAAALEwEAmpwYYKUKF+Os3baUndC0pDnwNAmLy1SUr2Gw0luxQuV/AwC6cEhVV5VRrwAAAABJRU5ErkJggg==",
177 },
178 },
179 },
180 }
181
Dusan Kasanb49ceb62017-04-13 00:00:36 +0200182 for index, td := range testData {
Dusan Kasan17e497e2017-04-10 22:44:22 +0200183 e, err := parsemail.Parse(strings.NewReader(td.mailData))
184 if err != nil {
185 t.Error(err)
186 }
187
Dusan Kasanb49ceb62017-04-13 00:00:36 +0200188 if td.subject != e.Subject {
189 t.Errorf("[Test Case %v] Wrong subject. Expected: %s, Got: %s", index, td.subject, e.Subject)
Dusan Kasan17e497e2017-04-10 22:44:22 +0200190 }
191
Dusan Kasanb49ceb62017-04-13 00:00:36 +0200192 if td.messageID != e.MessageID {
193 t.Errorf("[Test Case %v] Wrong messageID. Expected: '%s', Got: '%s'", index, td.messageID, e.MessageID)
Dusan Kasan17e497e2017-04-10 22:44:22 +0200194 }
195
Dusan Kasanb49ceb62017-04-13 00:00:36 +0200196 if !td.date.Equal(e.Date) {
197 t.Errorf("[Test Case %v] Wrong date. Expected: %v, Got: %v", index, td.date, e.Date)
Dusan Kasan17e497e2017-04-10 22:44:22 +0200198 }
199
Dusan Kasanb49ceb62017-04-13 00:00:36 +0200200 d := dereferenceAddressList(e.From)
201 if !assertAddressListEq(td.from, d) {
202 t.Errorf("[Test Case %v] Wrong from. Expected: %s, Got: %s", index, td.from, d)
Dusan Kasan17e497e2017-04-10 22:44:22 +0200203 }
204
Dusan Kasanb49ceb62017-04-13 00:00:36 +0200205 var sender mail.Address
206 if e.Sender != nil {
207 sender = *e.Sender
208 }
209 if td.sender != sender {
210 t.Errorf("[Test Case %v] Wrong sender. Expected: %s, Got: %s", index, td.sender, sender)
Dusan Kasan17e497e2017-04-10 22:44:22 +0200211 }
212
Dusan Kasanb49ceb62017-04-13 00:00:36 +0200213 d = dereferenceAddressList(e.To)
214 if !assertAddressListEq(td.to, d) {
215 t.Errorf("[Test Case %v] Wrong to. Expected: %s, Got: %s", index, td.to, d)
Dusan Kasan17e497e2017-04-10 22:44:22 +0200216 }
217
Dusan Kasanb49ceb62017-04-13 00:00:36 +0200218 d = dereferenceAddressList(e.Cc)
219 if !assertAddressListEq(td.cc, d) {
220 t.Errorf("[Test Case %v] Wrong cc. Expected: %s, Got: %s", index, td.cc, d)
Dusan Kasan17e497e2017-04-10 22:44:22 +0200221 }
222
Dusan Kasanb49ceb62017-04-13 00:00:36 +0200223 d = dereferenceAddressList(e.Bcc)
224 if !assertAddressListEq(td.bcc, d) {
225 t.Errorf("[Test Case %v] Wrong bcc. Expected: %s, Got: %s", index, td.bcc, d)
Dusan Kasan17e497e2017-04-10 22:44:22 +0200226 }
227
Dusan Kasanb49ceb62017-04-13 00:00:36 +0200228 if td.resentMessageID != e.ResentMessageID {
229 t.Errorf("[Test Case %v] Wrong resent messageID. Expected: '%s', Got: '%s'", index, td.resentMessageID, e.ResentMessageID)
Dusan Kasan17e497e2017-04-10 22:44:22 +0200230 }
231
Dusan Kasanb49ceb62017-04-13 00:00:36 +0200232 if !td.resentDate.Equal(e.ResentDate) && !td.resentDate.IsZero() && !e.ResentDate.IsZero() {
233 t.Errorf("[Test Case %v] Wrong resent date. Expected: %v, Got: %v", index, td.resentDate, e.ResentDate)
234 }
235
236 d = dereferenceAddressList(e.ResentFrom)
237 if !assertAddressListEq(td.resentFrom, d) {
238 t.Errorf("[Test Case %v] Wrong resent from. Expected: %s, Got: %s", index, td.resentFrom, d)
239 }
240
241 var resentSender mail.Address
242 if e.ResentSender != nil {
243 resentSender = *e.ResentSender
244 }
245 if td.resentSender != resentSender {
246 t.Errorf("[Test Case %v] Wrong resent sender. Expected: %s, Got: %s", index, td.resentSender, resentSender)
247 }
248
249 d = dereferenceAddressList(e.ResentTo)
250 if !assertAddressListEq(td.resentTo, d) {
251 t.Errorf("[Test Case %v] Wrong resent to. Expected: %s, Got: %s", index, td.resentTo, d)
252 }
253
254 d = dereferenceAddressList(e.ResentCc)
255 if !assertAddressListEq(td.resentCc, d) {
256 t.Errorf("[Test Case %v] Wrong resent cc. Expected: %s, Got: %s", index, td.resentCc, d)
257 }
258
259 d = dereferenceAddressList(e.ResentBcc)
260 if !assertAddressListEq(td.resentBcc, d) {
261 t.Errorf("[Test Case %v] Wrong resent bcc. Expected: %s, Got: %s", index, td.resentBcc, d)
262 }
263
264 if !assertSliceEq(td.inReplyTo, e.InReplyTo) {
265 t.Errorf("[Test Case %v] Wrong in reply to. Expected: %s, Got: %s", index, td.inReplyTo, e.InReplyTo)
266 }
267
268 if !assertSliceEq(td.references, e.References) {
269 t.Errorf("[Test Case %v] Wrong references. Expected: %s, Got: %s", index, td.references, e.References)
270 }
271
272 d = dereferenceAddressList(e.ReplyTo)
273 if !assertAddressListEq(td.replyTo, d) {
274 t.Errorf("[Test Case %v] Wrong reply to. Expected: %s, Got: %s", index, td.replyTo, d)
Dusan Kasan17e497e2017-04-10 22:44:22 +0200275 }
276
277 if td.htmlBody != e.HTMLBody {
Dusan Kasanb49ceb62017-04-13 00:00:36 +0200278 t.Errorf("[Test Case %v] Wrong html body. Expected: '%s', Got: '%s'", index, td.htmlBody, e.HTMLBody)
Dusan Kasan17e497e2017-04-10 22:44:22 +0200279 }
280
281 if td.textBody != e.TextBody {
Dusan Kasanb49ceb62017-04-13 00:00:36 +0200282 t.Errorf("[Test Case %v] Wrong text body. Expected: '%s', Got: '%s'", index, td.textBody, e.TextBody)
Dusan Kasan17e497e2017-04-10 22:44:22 +0200283 }
284
Dusan Kasan17e497e2017-04-10 22:44:22 +0200285
286 if len(td.attachments) != len(e.Attachments) {
Dusan Kasanb49ceb62017-04-13 00:00:36 +0200287 t.Errorf("[Test Case %v] Incorrect number of attachments! Expected: %v, Got: %v.", index, len(td.attachments), len(e.Attachments))
Dusan Kasan17e497e2017-04-10 22:44:22 +0200288 } else {
289 attachs := e.Attachments[:]
290
291 for _, ad := range(td.attachments) {
292 found := false
293
294 for i, ra := range(attachs) {
295 b, err := ioutil.ReadAll(ra.Data)
296 if err != nil {
297 t.Error(err)
298 }
299
300 encoded := base64.StdEncoding.EncodeToString(b)
Dusan Kasanb49ceb62017-04-13 00:00:36 +0200301 if ra.Filename == ad.filename && encoded == ad.base64data && ra.ContentType == ad.contentType {
Dusan Kasan17e497e2017-04-10 22:44:22 +0200302 found = true
303 attachs = append(attachs[:i], attachs[i+1:]...)
304 }
305 }
306
307 if !found {
Dusan Kasanb49ceb62017-04-13 00:00:36 +0200308 t.Errorf("[Test Case %v] Attachment not found: %s", index, ad.filename)
Dusan Kasan17e497e2017-04-10 22:44:22 +0200309 }
310 }
311
312 if len(attachs) != 0 {
Dusan Kasanb49ceb62017-04-13 00:00:36 +0200313 t.Errorf("[Test Case %v] Email contains %v unexpected attachments: %v", index, len(attachs), attachs)
Dusan Kasan17e497e2017-04-10 22:44:22 +0200314 }
315 }
316
317 if len(td.embeddedFiles) != len(e.EmbeddedFiles) {
Dusan Kasanb49ceb62017-04-13 00:00:36 +0200318 t.Errorf("[Test Case %v] Incorrect number of embedded files! Expected: %s, Got: %s.", index, len(td.embeddedFiles), len(e.EmbeddedFiles))
Dusan Kasan17e497e2017-04-10 22:44:22 +0200319 } else {
320 embeds := e.EmbeddedFiles[:]
321
322 for _, ad := range(td.embeddedFiles) {
323 found := false
324
325 for i, ra := range(embeds) {
326 b, err := ioutil.ReadAll(ra.Data)
327 if err != nil {
328 t.Error(err)
329 }
330
331 encoded := base64.StdEncoding.EncodeToString(b)
332
Dusan Kasanb49ceb62017-04-13 00:00:36 +0200333 if ra.CID == ad.cid && encoded == ad.base64data && ra.ContentType == ad.contentType {
Dusan Kasan17e497e2017-04-10 22:44:22 +0200334 found = true
335 embeds = append(embeds[:i], embeds[i+1:]...)
336 }
337 }
338
339 if !found {
Dusan Kasanb49ceb62017-04-13 00:00:36 +0200340 t.Errorf("[Test Case %v] Embedded file not found: %s", index, ad.cid)
Dusan Kasan17e497e2017-04-10 22:44:22 +0200341 }
342 }
343
344 if len(embeds) != 0 {
Dusan Kasanb49ceb62017-04-13 00:00:36 +0200345 t.Errorf("[Test Case %v] Email contains %v unexpected embedded files: %v", index, len(embeds), embeds)
Dusan Kasan17e497e2017-04-10 22:44:22 +0200346 }
347 }
348 }
349}
350
351func parseDate(in string) time.Time {
352 out, err := time.Parse(time.RFC1123Z, in)
353 if err != nil {
354 panic(err)
355 }
356
357 return out
358}
359
360type attachmentData struct{
361 filename string
Dusan Kasanb49ceb62017-04-13 00:00:36 +0200362 contentType string
Dusan Kasan17e497e2017-04-10 22:44:22 +0200363 base64data string
364}
365
366type embeddedFileData struct{
367 cid string
Dusan Kasanb49ceb62017-04-13 00:00:36 +0200368 contentType string
Dusan Kasan17e497e2017-04-10 22:44:22 +0200369 base64data string
370}
371
372func assertSliceEq(a, b []string) bool {
373 if len(a) == len(b) && len(a) == 0 {
374 return true
375 }
376
377 if a == nil && b == nil {
378 return true;
379 }
380
381 if a == nil || b == nil {
382 return false;
383 }
384
385 if len(a) != len(b) {
386 return false
387 }
388
389 for i := range a {
390 if a[i] != b[i] {
391 return false
392 }
393 }
394
395 return true
396}
397
Dusan Kasanb49ceb62017-04-13 00:00:36 +0200398func assertAddressListEq(a, b []mail.Address) bool {
399 if len(a) == len(b) && len(a) == 0 {
400 return true
401 }
402
403 if a == nil && b == nil {
404 return true;
405 }
406
407 if a == nil || b == nil {
408 return false;
409 }
410
411 if len(a) != len(b) {
412 return false
413 }
414
415 for i := range a {
416 if a[i] != b[i] {
417 return false
418 }
419 }
420
421 return true
422}
423
424func dereferenceAddressList(al []*mail.Address) (result []mail.Address) {
425 for _, a := range(al) {
426 result = append(result, *a)
427 }
428
429 return
430}
431
Dusan Kasan17e497e2017-04-10 22:44:22 +0200432var Data1 = `From: =?UTF-8?Q?Peter_Pahol=C3=ADk?= <peter.paholik@gmail.com>
433Date: Fri, 7 Apr 2017 09:17:26 +0200
434Message-ID: <CACtgX4kNXE7T5XKSKeH_zEcfUUmf2vXVASxYjaaK9cCn-3zb_g@mail.gmail.com>
435Subject: Test Subject 1
436To: dusan@kasan.sk
437Content-Type: multipart/mixed; boundary=f403045f1dcc043a44054c8e6bbf
438
439--f403045f1dcc043a44054c8e6bbf
440Content-Type: multipart/alternative; boundary=f403045f1dcc043a3f054c8e6bbd
441
442--f403045f1dcc043a3f054c8e6bbd
443Content-Type: text/plain; charset=UTF-8
444
445
446
447--f403045f1dcc043a3f054c8e6bbd
448Content-Type: text/html; charset=UTF-8
449
450<div dir="ltr"><br></div>
451
452--f403045f1dcc043a3f054c8e6bbd--
453--f403045f1dcc043a44054c8e6bbf
454Content-Type: application/pdf;
455 name="=?UTF-8?Q?Peter_Paholi=CC=81k_1?=
456 =?UTF-8?Q?_4_2017_2017=2D04=2D07=2Epdf?="
457Content-Disposition: attachment;
458 filename="=?UTF-8?Q?Peter_Paholi=CC=81k_1?=
459 =?UTF-8?Q?_4_2017_2017=2D04=2D07=2Epdf?="
460Content-Transfer-Encoding: base64
461X-Attachment-Id: f_j17i0f0d0
462
463JVBERi0xLjQNCiW1tbW1DQoxIDAgb2JqDQo8PC9UeXBlL0NhdGFsb2cvUGFnZXMgMiAwIFIvTGFu
464Zyhlbi1VUykgL1N0cnVjdFRyZWVSb290IDY3IDAgUi9NYXJrSW5mbzw8L01hcmtlZCB0cnVlPj4v
465T3V0cHV0SW50ZW50c1s8PC9UeXBlL091dHB1dEludGVudC9TL0dUU19QREZBMS9PdXRwdXRDb25k
466ZXYgMzk1MzYyDQo+Pg0Kc3RhcnR4cmVmDQo0MTk4ODUNCiUlRU9GDQo=
467--f403045f1dcc043a44054c8e6bbf--
468`
469
470var Data2 = `Subject: Re: Test Subject 2
471To: info@receiver.com
472References: <2f6b7595-c01e-46e5-42bc-f263e1c4282d@receiver.com>
473 <9ff38d03-c4ab-89b7-9328-e99d5e24e3ba@domain.com>
474Cc: Cc Man <ccman@gmail.com>
475From: Sender Man <sender@domain.com>
476Message-ID: <0e9a21b4-01dc-e5c1-dcd6-58ce5aa61f4f@receiver.com>
477Date: Fri, 7 Apr 2017 12:59:55 +0200
478User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:45.0)
479 Gecko/20100101 Thunderbird/45.8.0
480MIME-Version: 1.0
481In-Reply-To: <9ff38d03-c4ab-89b7-9328-e99d5e24e3ba@receiver.eu>
482Content-Type: multipart/alternative;
483 boundary="------------C70C0458A558E585ACB75FB4"
484
485This is a multi-part message in MIME format.
486--------------C70C0458A558E585ACB75FB4
487Content-Type: text/plain; charset=utf-8; format=flowed
488Content-Transfer-Encoding: 8bit
489
490First level
491> Second level
492>> Third level
493>
494
495
496--------------C70C0458A558E585ACB75FB4
497Content-Type: multipart/related;
498 boundary="------------5DB4A1356834BB602A5F88B2"
499
500
501--------------5DB4A1356834BB602A5F88B2
502Content-Type: text/html; charset=utf-8
503Content-Transfer-Encoding: 8bit
504
505<html>data<img src="part2.9599C449.04E5EC81@develhell.com"/></html>
506
507--------------5DB4A1356834BB602A5F88B2
508Content-Type: image/png
509Content-Transfer-Encoding: base64
510Content-ID: <part2.9599C449.04E5EC81@develhell.com>
511
512iVBORw0KGgoAAAANSUhEUgAAAQEAAAAYCAIAAAB1IN9NAAAACXBIWXMAAAsTAAALEwEAmpwY
513YKUKF+Os3baUndC0pDnwNAmLy1SUr2Gw0luxQuV/AwC6cEhVV5VRrwAAAABJRU5ErkJggg==
514--------------5DB4A1356834BB602A5F88B2
515
516--------------C70C0458A558E585ACB75FB4--
Dusan Kasanb49ceb62017-04-13 00:00:36 +0200517`
518
519var RFC5322_Example_A11 = `From: John Doe <jdoe@machine.example>
520Sender: Michael Jones <mjones@machine.example>
521To: Mary Smith <mary@example.net>
522Subject: Saying Hello
523Date: Fri, 21 Nov 1997 09:55:06 -0600
524Message-ID: <1234@local.machine.example>
525
526This is a message just to say hello.
527So, "Hello".
528`
529
530var RFC5322_Example_A12 = `From: "Joe Q. Public" <john.q.public@example.com>
531To: Mary Smith <mary@x.test>, jdoe@example.org, Who? <one@y.test>
532Cc: <boss@nil.test>, "Giant; \"Big\" Box" <sysservices@example.net>
533Date: Tue, 1 Jul 2003 10:52:37 +0200
534Message-ID: <5678.21-Nov-1997@example.com>
535
536Hi everyone.
537`
538
539//todo: not yet implemented in net/mail
540//once there is support for this, add it
541var RFC5322_Example_A13 = `From: Pete <pete@silly.example>
542To: A Group:Ed Jones <c@a.test>,joe@where.test,John <jdoe@one.test>;
543Cc: Undisclosed recipients:;
544Date: Thu, 13 Feb 1969 23:32:54 -0330
545Message-ID: <testabcd.1234@silly.example>
546
547Testing.
548`
549
550//we skipped the first message bcause it's the same as A 1.1
551var RFC5322_Example_A2a = `From: Mary Smith <mary@example.net>
552To: John Doe <jdoe@machine.example>
553Reply-To: "Mary Smith: Personal Account" <smith@home.example>
554Subject: Re: Saying Hello
555Date: Fri, 21 Nov 1997 10:01:10 -0600
556Message-ID: <3456@example.net>
557In-Reply-To: <1234@local.machine.example>
558References: <1234@local.machine.example>
559
560This is a reply to your hello.
561`
562
563var RFC5322_Example_A2b = `To: "Mary Smith: Personal Account" <smith@home.example>
564From: John Doe <jdoe@machine.example>
565Subject: Re: Saying Hello
566Date: Fri, 21 Nov 1997 11:00:00 -0600
567Message-ID: <abcd.1234@local.machine.test>
568In-Reply-To: <3456@example.net>
569References: <1234@local.machine.example> <3456@example.net>
570
571This is a reply to your reply.
572`
573
574var RFC5322_Example_A3 = `Resent-From: Mary Smith <mary@example.net>
575Resent-To: Jane Brown <j-brown@other.example>
576Resent-Date: Mon, 24 Nov 1997 14:22:01 -0800
577Resent-Message-ID: <78910@example.net>
578From: John Doe <jdoe@machine.example>
579To: Mary Smith <mary@example.net>
580Subject: Saying Hello
581Date: Fri, 21 Nov 1997 09:55:06 -0600
582Message-ID: <1234@local.machine.example>
583
584This is a message just to say hello.
585So, "Hello".`
586
587var RFC5322_Example_A4 = `Received: from x.y.test
588 by example.net
589 via TCP
590 with ESMTP
591 id ABC12345
592 for <mary@example.net>; 21 Nov 1997 10:05:43 -0600
593Received: from node.example by x.y.test; 21 Nov 1997 10:01:22 -0600
594From: John Doe <jdoe@node.example>
595To: Mary Smith <mary@example.net>
596Subject: Saying Hello
597Date: Fri, 21 Nov 1997 09:55:06 -0600
598Message-ID: <1234@local.node.example>
599
600This is a message just to say hello.
601So, "Hello".`