Dusan Kasan | c2129de | 2017-04-13 10:42:21 +0200 | [diff] [blame] | 1 | package parsemail |
Dusan Kasan | 17e497e | 2017-04-10 22:44:22 +0200 | [diff] [blame] | 2 | |
| 3 | import ( |
Dusan Kasan | 17e497e | 2017-04-10 22:44:22 +0200 | [diff] [blame] | 4 | "encoding/base64" |
| 5 | "io/ioutil" |
Dusan Kasan | 4595dfe | 2017-04-13 00:38:24 +0200 | [diff] [blame] | 6 | "net/mail" |
| 7 | "strings" |
| 8 | "testing" |
| 9 | "time" |
Dusan Kasan | 17e497e | 2017-04-10 22:44:22 +0200 | [diff] [blame] | 10 | ) |
| 11 | |
| 12 | func TestParseEmail(t *testing.T) { |
Dusan Kasan | 4595dfe | 2017-04-13 00:38:24 +0200 | [diff] [blame] | 13 | var testData = map[int]struct { |
Dusan Kasan | 17e497e | 2017-04-10 22:44:22 +0200 | [diff] [blame] | 14 | mailData string |
| 15 | |
Dusan Kasan | 4595dfe | 2017-04-13 00:38:24 +0200 | [diff] [blame] | 16 | subject string |
| 17 | date time.Time |
| 18 | from []mail.Address |
| 19 | sender mail.Address |
| 20 | to []mail.Address |
| 21 | replyTo []mail.Address |
| 22 | cc []mail.Address |
| 23 | bcc []mail.Address |
| 24 | messageID string |
| 25 | resentDate time.Time |
| 26 | resentFrom []mail.Address |
| 27 | resentSender mail.Address |
| 28 | resentTo []mail.Address |
| 29 | resentReplyTo []mail.Address |
| 30 | resentCc []mail.Address |
| 31 | resentBcc []mail.Address |
Dusan Kasan | b49ceb6 | 2017-04-13 00:00:36 +0200 | [diff] [blame] | 32 | resentMessageID string |
Dusan Kasan | 4595dfe | 2017-04-13 00:38:24 +0200 | [diff] [blame] | 33 | inReplyTo []string |
| 34 | references []string |
| 35 | htmlBody string |
| 36 | textBody string |
| 37 | attachments []attachmentData |
| 38 | embeddedFiles []embeddedFileData |
| 39 | headerCheck func(mail.Header, *testing.T) |
Dusan Kasan | 17e497e | 2017-04-10 22:44:22 +0200 | [diff] [blame] | 40 | }{ |
Dusan Kasan | b49ceb6 | 2017-04-13 00:00:36 +0200 | [diff] [blame] | 41 | 1: { |
Dusan Kasan | 45ca264 | 2017-04-18 10:39:35 +0200 | [diff] [blame] | 42 | mailData: rfc5322exampleA11, |
Dusan Kasan | 4595dfe | 2017-04-13 00:38:24 +0200 | [diff] [blame] | 43 | subject: "Saying Hello", |
Dusan Kasan | b49ceb6 | 2017-04-13 00:00:36 +0200 | [diff] [blame] | 44 | from: []mail.Address{ |
Dusan Kasan | 45ca264 | 2017-04-18 10:39:35 +0200 | [diff] [blame] | 45 | { |
| 46 | Name: "John Doe", |
| 47 | Address: "jdoe@machine.example", |
| 48 | }, |
Dusan Kasan | b49ceb6 | 2017-04-13 00:00:36 +0200 | [diff] [blame] | 49 | }, |
| 50 | to: []mail.Address{ |
Dusan Kasan | 45ca264 | 2017-04-18 10:39:35 +0200 | [diff] [blame] | 51 | { |
| 52 | Name: "Mary Smith", |
| 53 | Address: "mary@example.net", |
| 54 | }, |
Dusan Kasan | b49ceb6 | 2017-04-13 00:00:36 +0200 | [diff] [blame] | 55 | }, |
Dusan Kasan | 45ca264 | 2017-04-18 10:39:35 +0200 | [diff] [blame] | 56 | sender: mail.Address{ |
| 57 | Name: "Michael Jones", |
| 58 | Address: "mjones@machine.example", |
| 59 | }, |
Dusan Kasan | b49ceb6 | 2017-04-13 00:00:36 +0200 | [diff] [blame] | 60 | messageID: "1234@local.machine.example", |
Dusan Kasan | 4595dfe | 2017-04-13 00:38:24 +0200 | [diff] [blame] | 61 | date: parseDate("Fri, 21 Nov 1997 09:55:06 -0600"), |
Dusan Kasan | b49ceb6 | 2017-04-13 00:00:36 +0200 | [diff] [blame] | 62 | textBody: `This is a message just to say hello. |
| 63 | So, "Hello".`, |
| 64 | }, |
| 65 | 2: { |
Dusan Kasan | 45ca264 | 2017-04-18 10:39:35 +0200 | [diff] [blame] | 66 | mailData: rfc5322exampleA12, |
Dusan Kasan | b49ceb6 | 2017-04-13 00:00:36 +0200 | [diff] [blame] | 67 | from: []mail.Address{ |
Dusan Kasan | 45ca264 | 2017-04-18 10:39:35 +0200 | [diff] [blame] | 68 | { |
| 69 | Name: "Joe Q. Public", |
| 70 | Address: "john.q.public@example.com", |
| 71 | }, |
Dusan Kasan | b49ceb6 | 2017-04-13 00:00:36 +0200 | [diff] [blame] | 72 | }, |
| 73 | to: []mail.Address{ |
Dusan Kasan | 45ca264 | 2017-04-18 10:39:35 +0200 | [diff] [blame] | 74 | { |
| 75 | Name: "Mary Smith", |
| 76 | Address: "mary@x.test", |
| 77 | }, |
| 78 | { |
| 79 | Name: "", |
| 80 | Address: "jdoe@example.org", |
| 81 | }, |
| 82 | { |
| 83 | Name: "Who?", |
| 84 | Address: "one@y.test", |
| 85 | }, |
Dusan Kasan | b49ceb6 | 2017-04-13 00:00:36 +0200 | [diff] [blame] | 86 | }, |
| 87 | cc: []mail.Address{ |
Dusan Kasan | 45ca264 | 2017-04-18 10:39:35 +0200 | [diff] [blame] | 88 | { |
| 89 | Name: "", |
| 90 | Address: "boss@nil.test", |
| 91 | }, |
| 92 | { |
| 93 | Name: "Giant; \"Big\" Box", |
| 94 | Address: "sysservices@example.net", |
| 95 | }, |
Dusan Kasan | b49ceb6 | 2017-04-13 00:00:36 +0200 | [diff] [blame] | 96 | }, |
| 97 | messageID: "5678.21-Nov-1997@example.com", |
Dusan Kasan | 4595dfe | 2017-04-13 00:38:24 +0200 | [diff] [blame] | 98 | date: parseDate("Tue, 01 Jul 2003 10:52:37 +0200"), |
| 99 | textBody: `Hi everyone.`, |
Dusan Kasan | b49ceb6 | 2017-04-13 00:00:36 +0200 | [diff] [blame] | 100 | }, |
| 101 | 3: { |
Dusan Kasan | 45ca264 | 2017-04-18 10:39:35 +0200 | [diff] [blame] | 102 | mailData: rfc5322exampleA2a, |
Dusan Kasan | 4595dfe | 2017-04-13 00:38:24 +0200 | [diff] [blame] | 103 | subject: "Re: Saying Hello", |
Dusan Kasan | b49ceb6 | 2017-04-13 00:00:36 +0200 | [diff] [blame] | 104 | from: []mail.Address{ |
Dusan Kasan | 45ca264 | 2017-04-18 10:39:35 +0200 | [diff] [blame] | 105 | { |
| 106 | Name: "Mary Smith", |
| 107 | Address: "mary@example.net", |
| 108 | }, |
Dusan Kasan | b49ceb6 | 2017-04-13 00:00:36 +0200 | [diff] [blame] | 109 | }, |
| 110 | replyTo: []mail.Address{ |
Dusan Kasan | 45ca264 | 2017-04-18 10:39:35 +0200 | [diff] [blame] | 111 | { |
| 112 | Name: "Mary Smith: Personal Account", |
| 113 | Address: "smith@home.example", |
| 114 | }, |
Dusan Kasan | b49ceb6 | 2017-04-13 00:00:36 +0200 | [diff] [blame] | 115 | }, |
| 116 | to: []mail.Address{ |
Dusan Kasan | 45ca264 | 2017-04-18 10:39:35 +0200 | [diff] [blame] | 117 | { |
| 118 | Name: "John Doe", |
| 119 | Address: "jdoe@machine.example", |
| 120 | }, |
Dusan Kasan | b49ceb6 | 2017-04-13 00:00:36 +0200 | [diff] [blame] | 121 | }, |
Dusan Kasan | 4595dfe | 2017-04-13 00:38:24 +0200 | [diff] [blame] | 122 | messageID: "3456@example.net", |
| 123 | inReplyTo: []string{"1234@local.machine.example"}, |
Dusan Kasan | b49ceb6 | 2017-04-13 00:00:36 +0200 | [diff] [blame] | 124 | references: []string{"1234@local.machine.example"}, |
Dusan Kasan | 4595dfe | 2017-04-13 00:38:24 +0200 | [diff] [blame] | 125 | date: parseDate("Fri, 21 Nov 1997 10:01:10 -0600"), |
| 126 | textBody: `This is a reply to your hello.`, |
Dusan Kasan | b49ceb6 | 2017-04-13 00:00:36 +0200 | [diff] [blame] | 127 | }, |
| 128 | 4: { |
Dusan Kasan | 45ca264 | 2017-04-18 10:39:35 +0200 | [diff] [blame] | 129 | mailData: rfc5322exampleA2b, |
Dusan Kasan | 4595dfe | 2017-04-13 00:38:24 +0200 | [diff] [blame] | 130 | subject: "Re: Saying Hello", |
Dusan Kasan | b49ceb6 | 2017-04-13 00:00:36 +0200 | [diff] [blame] | 131 | from: []mail.Address{ |
Dusan Kasan | 45ca264 | 2017-04-18 10:39:35 +0200 | [diff] [blame] | 132 | { |
| 133 | Name: "John Doe", |
| 134 | Address: "jdoe@machine.example", |
| 135 | }, |
Dusan Kasan | b49ceb6 | 2017-04-13 00:00:36 +0200 | [diff] [blame] | 136 | }, |
| 137 | to: []mail.Address{ |
Dusan Kasan | 45ca264 | 2017-04-18 10:39:35 +0200 | [diff] [blame] | 138 | { |
| 139 | Name: "Mary Smith: Personal Account", |
| 140 | Address: "smith@home.example", |
| 141 | }, |
Dusan Kasan | b49ceb6 | 2017-04-13 00:00:36 +0200 | [diff] [blame] | 142 | }, |
Dusan Kasan | 4595dfe | 2017-04-13 00:38:24 +0200 | [diff] [blame] | 143 | messageID: "abcd.1234@local.machine.test", |
| 144 | inReplyTo: []string{"3456@example.net"}, |
Dusan Kasan | b49ceb6 | 2017-04-13 00:00:36 +0200 | [diff] [blame] | 145 | references: []string{"1234@local.machine.example", "3456@example.net"}, |
Dusan Kasan | 4595dfe | 2017-04-13 00:38:24 +0200 | [diff] [blame] | 146 | date: parseDate("Fri, 21 Nov 1997 11:00:00 -0600"), |
| 147 | textBody: `This is a reply to your reply.`, |
Dusan Kasan | b49ceb6 | 2017-04-13 00:00:36 +0200 | [diff] [blame] | 148 | }, |
| 149 | 5: { |
Dusan Kasan | 45ca264 | 2017-04-18 10:39:35 +0200 | [diff] [blame] | 150 | mailData: rfc5322exampleA3, |
Dusan Kasan | 4595dfe | 2017-04-13 00:38:24 +0200 | [diff] [blame] | 151 | subject: "Saying Hello", |
Dusan Kasan | b49ceb6 | 2017-04-13 00:00:36 +0200 | [diff] [blame] | 152 | from: []mail.Address{ |
Dusan Kasan | 45ca264 | 2017-04-18 10:39:35 +0200 | [diff] [blame] | 153 | { |
| 154 | Name: "John Doe", |
| 155 | Address: "jdoe@machine.example", |
| 156 | }, |
Dusan Kasan | b49ceb6 | 2017-04-13 00:00:36 +0200 | [diff] [blame] | 157 | }, |
| 158 | to: []mail.Address{ |
Dusan Kasan | 45ca264 | 2017-04-18 10:39:35 +0200 | [diff] [blame] | 159 | { |
| 160 | Name: "Mary Smith", |
| 161 | Address: "mary@example.net", |
| 162 | }, |
Dusan Kasan | b49ceb6 | 2017-04-13 00:00:36 +0200 | [diff] [blame] | 163 | }, |
| 164 | messageID: "1234@local.machine.example", |
Dusan Kasan | 4595dfe | 2017-04-13 00:38:24 +0200 | [diff] [blame] | 165 | date: parseDate("Fri, 21 Nov 1997 09:55:06 -0600"), |
Dusan Kasan | b49ceb6 | 2017-04-13 00:00:36 +0200 | [diff] [blame] | 166 | resentFrom: []mail.Address{ |
Dusan Kasan | 45ca264 | 2017-04-18 10:39:35 +0200 | [diff] [blame] | 167 | { |
| 168 | Name: "Mary Smith", |
| 169 | Address: "mary@example.net", |
| 170 | }, |
Dusan Kasan | b49ceb6 | 2017-04-13 00:00:36 +0200 | [diff] [blame] | 171 | }, |
| 172 | resentTo: []mail.Address{ |
Dusan Kasan | 45ca264 | 2017-04-18 10:39:35 +0200 | [diff] [blame] | 173 | { |
| 174 | Name: "Jane Brown", |
| 175 | Address: "j-brown@other.example", |
| 176 | }, |
Dusan Kasan | b49ceb6 | 2017-04-13 00:00:36 +0200 | [diff] [blame] | 177 | }, |
| 178 | resentMessageID: "78910@example.net", |
Dusan Kasan | 4595dfe | 2017-04-13 00:38:24 +0200 | [diff] [blame] | 179 | resentDate: parseDate("Mon, 24 Nov 1997 14:22:01 -0800"), |
Dusan Kasan | b49ceb6 | 2017-04-13 00:00:36 +0200 | [diff] [blame] | 180 | textBody: `This is a message just to say hello. |
| 181 | So, "Hello".`, |
| 182 | }, |
| 183 | 6: { |
Dusan Kasan | 45ca264 | 2017-04-18 10:39:35 +0200 | [diff] [blame] | 184 | mailData: data1, |
Dusan Kasan | f4376a6 | 2017-05-23 21:03:55 +0200 | [diff] [blame] | 185 | subject: "Peter Paholík", |
Dusan Kasan | b49ceb6 | 2017-04-13 00:00:36 +0200 | [diff] [blame] | 186 | from: []mail.Address{ |
Dusan Kasan | 45ca264 | 2017-04-18 10:39:35 +0200 | [diff] [blame] | 187 | { |
| 188 | Name: "Peter Paholík", |
| 189 | Address: "peter.paholik@gmail.com", |
| 190 | }, |
Dusan Kasan | b49ceb6 | 2017-04-13 00:00:36 +0200 | [diff] [blame] | 191 | }, |
| 192 | to: []mail.Address{ |
Dusan Kasan | 45ca264 | 2017-04-18 10:39:35 +0200 | [diff] [blame] | 193 | { |
| 194 | Name: "", |
| 195 | Address: "dusan@kasan.sk", |
| 196 | }, |
Dusan Kasan | b49ceb6 | 2017-04-13 00:00:36 +0200 | [diff] [blame] | 197 | }, |
Dusan Kasan | 17e497e | 2017-04-10 22:44:22 +0200 | [diff] [blame] | 198 | messageID: "CACtgX4kNXE7T5XKSKeH_zEcfUUmf2vXVASxYjaaK9cCn-3zb_g@mail.gmail.com", |
Dusan Kasan | 4595dfe | 2017-04-13 00:38:24 +0200 | [diff] [blame] | 199 | date: parseDate("Fri, 07 Apr 2017 09:17:26 +0200"), |
| 200 | htmlBody: "<div dir=\"ltr\"><br></div>", |
Dusan Kasan | 17e497e | 2017-04-10 22:44:22 +0200 | [diff] [blame] | 201 | attachments: []attachmentData{ |
| 202 | { |
Dusan Kasan | 4595dfe | 2017-04-13 00:38:24 +0200 | [diff] [blame] | 203 | filename: "Peter Paholík 1 4 2017 2017-04-07.pdf", |
Dusan Kasan | b49ceb6 | 2017-04-13 00:00:36 +0200 | [diff] [blame] | 204 | contentType: "application/pdf", |
Dusan Kasan | 4595dfe | 2017-04-13 00:38:24 +0200 | [diff] [blame] | 205 | base64data: "JVBERi0xLjQNCiW1tbW1DQoxIDAgb2JqDQo8PC9UeXBlL0NhdGFsb2cvUGFnZXMgMiAwIFIvTGFuZyhlbi1VUykgL1N0cnVjdFRyZWVSb290IDY3IDAgUi9NYXJrSW5mbzw8L01hcmtlZCB0cnVlPj4vT3V0cHV0SW50ZW50c1s8PC9UeXBlL091dHB1dEludGVudC9TL0dUU19QREZBMS9PdXRwdXRDb25kZXYgMzk1MzYyDQo+Pg0Kc3RhcnR4cmVmDQo0MTk4ODUNCiUlRU9GDQo=", |
Dusan Kasan | 17e497e | 2017-04-10 22:44:22 +0200 | [diff] [blame] | 206 | }, |
| 207 | }, |
| 208 | }, |
Dusan Kasan | b49ceb6 | 2017-04-13 00:00:36 +0200 | [diff] [blame] | 209 | 7: { |
Dusan Kasan | 45ca264 | 2017-04-18 10:39:35 +0200 | [diff] [blame] | 210 | mailData: data2, |
Dusan Kasan | 4595dfe | 2017-04-13 00:38:24 +0200 | [diff] [blame] | 211 | subject: "Re: Test Subject 2", |
Dusan Kasan | b49ceb6 | 2017-04-13 00:00:36 +0200 | [diff] [blame] | 212 | from: []mail.Address{ |
Dusan Kasan | 45ca264 | 2017-04-18 10:39:35 +0200 | [diff] [blame] | 213 | { |
| 214 | Name: "Sender Man", |
| 215 | Address: "sender@domain.com", |
| 216 | }, |
Dusan Kasan | b49ceb6 | 2017-04-13 00:00:36 +0200 | [diff] [blame] | 217 | }, |
| 218 | to: []mail.Address{ |
Dusan Kasan | 45ca264 | 2017-04-18 10:39:35 +0200 | [diff] [blame] | 219 | { |
| 220 | Name: "", |
| 221 | Address: "info@receiver.com", |
| 222 | }, |
Dusan Kasan | b49ceb6 | 2017-04-13 00:00:36 +0200 | [diff] [blame] | 223 | }, |
| 224 | cc: []mail.Address{ |
Dusan Kasan | 45ca264 | 2017-04-18 10:39:35 +0200 | [diff] [blame] | 225 | { |
| 226 | Name: "Cc Man", |
| 227 | Address: "ccman@gmail.com", |
| 228 | }, |
Dusan Kasan | b49ceb6 | 2017-04-13 00:00:36 +0200 | [diff] [blame] | 229 | }, |
Dusan Kasan | 4595dfe | 2017-04-13 00:38:24 +0200 | [diff] [blame] | 230 | messageID: "0e9a21b4-01dc-e5c1-dcd6-58ce5aa61f4f@receiver.com", |
| 231 | inReplyTo: []string{"9ff38d03-c4ab-89b7-9328-e99d5e24e3ba@receiver.eu"}, |
Dusan Kasan | 17e497e | 2017-04-10 22:44:22 +0200 | [diff] [blame] | 232 | references: []string{"2f6b7595-c01e-46e5-42bc-f263e1c4282d@receiver.com", "9ff38d03-c4ab-89b7-9328-e99d5e24e3ba@domain.com"}, |
Dusan Kasan | 4595dfe | 2017-04-13 00:38:24 +0200 | [diff] [blame] | 233 | date: parseDate("Fri, 07 Apr 2017 12:59:55 +0200"), |
| 234 | htmlBody: `<html>data<img src="part2.9599C449.04E5EC81@develhell.com"/></html>`, |
Dusan Kasan | 17e497e | 2017-04-10 22:44:22 +0200 | [diff] [blame] | 235 | textBody: `First level |
| 236 | > Second level |
| 237 | >> Third level |
| 238 | > |
| 239 | `, |
| 240 | embeddedFiles: []embeddedFileData{ |
| 241 | { |
Dusan Kasan | 4595dfe | 2017-04-13 00:38:24 +0200 | [diff] [blame] | 242 | cid: "part2.9599C449.04E5EC81@develhell.com", |
Dusan Kasan | b49ceb6 | 2017-04-13 00:00:36 +0200 | [diff] [blame] | 243 | contentType: "image/png", |
Dusan Kasan | 4595dfe | 2017-04-13 00:38:24 +0200 | [diff] [blame] | 244 | base64data: "iVBORw0KGgoAAAANSUhEUgAAAQEAAAAYCAIAAAB1IN9NAAAACXBIWXMAAAsTAAALEwEAmpwYYKUKF+Os3baUndC0pDnwNAmLy1SUr2Gw0luxQuV/AwC6cEhVV5VRrwAAAABJRU5ErkJggg==", |
Dusan Kasan | 17e497e | 2017-04-10 22:44:22 +0200 | [diff] [blame] | 245 | }, |
| 246 | }, |
| 247 | }, |
| 248 | } |
| 249 | |
Dusan Kasan | b49ceb6 | 2017-04-13 00:00:36 +0200 | [diff] [blame] | 250 | for index, td := range testData { |
Antonio | 331b118 | 2019-01-15 09:58:52 +0100 | [diff] [blame^] | 251 | m, err := mail.ReadMessage(strings.NewReader(td.mailData)) |
| 252 | if err != nil { |
| 253 | t.Error(err) |
| 254 | } |
| 255 | e, err := Parse(m) |
Dusan Kasan | 17e497e | 2017-04-10 22:44:22 +0200 | [diff] [blame] | 256 | if err != nil { |
| 257 | t.Error(err) |
| 258 | } |
| 259 | |
Dusan Kasan | b49ceb6 | 2017-04-13 00:00:36 +0200 | [diff] [blame] | 260 | if td.subject != e.Subject { |
| 261 | t.Errorf("[Test Case %v] Wrong subject. Expected: %s, Got: %s", index, td.subject, e.Subject) |
Dusan Kasan | 17e497e | 2017-04-10 22:44:22 +0200 | [diff] [blame] | 262 | } |
| 263 | |
Dusan Kasan | b49ceb6 | 2017-04-13 00:00:36 +0200 | [diff] [blame] | 264 | if td.messageID != e.MessageID { |
| 265 | t.Errorf("[Test Case %v] Wrong messageID. Expected: '%s', Got: '%s'", index, td.messageID, e.MessageID) |
Dusan Kasan | 17e497e | 2017-04-10 22:44:22 +0200 | [diff] [blame] | 266 | } |
| 267 | |
Dusan Kasan | b49ceb6 | 2017-04-13 00:00:36 +0200 | [diff] [blame] | 268 | if !td.date.Equal(e.Date) { |
| 269 | t.Errorf("[Test Case %v] Wrong date. Expected: %v, Got: %v", index, td.date, e.Date) |
Dusan Kasan | 17e497e | 2017-04-10 22:44:22 +0200 | [diff] [blame] | 270 | } |
| 271 | |
Dusan Kasan | b49ceb6 | 2017-04-13 00:00:36 +0200 | [diff] [blame] | 272 | d := dereferenceAddressList(e.From) |
| 273 | if !assertAddressListEq(td.from, d) { |
| 274 | t.Errorf("[Test Case %v] Wrong from. Expected: %s, Got: %s", index, td.from, d) |
Dusan Kasan | 17e497e | 2017-04-10 22:44:22 +0200 | [diff] [blame] | 275 | } |
| 276 | |
Dusan Kasan | b49ceb6 | 2017-04-13 00:00:36 +0200 | [diff] [blame] | 277 | var sender mail.Address |
| 278 | if e.Sender != nil { |
| 279 | sender = *e.Sender |
| 280 | } |
| 281 | if td.sender != sender { |
| 282 | t.Errorf("[Test Case %v] Wrong sender. Expected: %s, Got: %s", index, td.sender, sender) |
Dusan Kasan | 17e497e | 2017-04-10 22:44:22 +0200 | [diff] [blame] | 283 | } |
| 284 | |
Dusan Kasan | b49ceb6 | 2017-04-13 00:00:36 +0200 | [diff] [blame] | 285 | d = dereferenceAddressList(e.To) |
| 286 | if !assertAddressListEq(td.to, d) { |
| 287 | t.Errorf("[Test Case %v] Wrong to. Expected: %s, Got: %s", index, td.to, d) |
Dusan Kasan | 17e497e | 2017-04-10 22:44:22 +0200 | [diff] [blame] | 288 | } |
| 289 | |
Dusan Kasan | b49ceb6 | 2017-04-13 00:00:36 +0200 | [diff] [blame] | 290 | d = dereferenceAddressList(e.Cc) |
| 291 | if !assertAddressListEq(td.cc, d) { |
| 292 | t.Errorf("[Test Case %v] Wrong cc. Expected: %s, Got: %s", index, td.cc, d) |
Dusan Kasan | 17e497e | 2017-04-10 22:44:22 +0200 | [diff] [blame] | 293 | } |
| 294 | |
Dusan Kasan | b49ceb6 | 2017-04-13 00:00:36 +0200 | [diff] [blame] | 295 | d = dereferenceAddressList(e.Bcc) |
| 296 | if !assertAddressListEq(td.bcc, d) { |
| 297 | t.Errorf("[Test Case %v] Wrong bcc. Expected: %s, Got: %s", index, td.bcc, d) |
Dusan Kasan | 17e497e | 2017-04-10 22:44:22 +0200 | [diff] [blame] | 298 | } |
| 299 | |
Dusan Kasan | b49ceb6 | 2017-04-13 00:00:36 +0200 | [diff] [blame] | 300 | if td.resentMessageID != e.ResentMessageID { |
| 301 | t.Errorf("[Test Case %v] Wrong resent messageID. Expected: '%s', Got: '%s'", index, td.resentMessageID, e.ResentMessageID) |
Dusan Kasan | 17e497e | 2017-04-10 22:44:22 +0200 | [diff] [blame] | 302 | } |
| 303 | |
Dusan Kasan | b49ceb6 | 2017-04-13 00:00:36 +0200 | [diff] [blame] | 304 | if !td.resentDate.Equal(e.ResentDate) && !td.resentDate.IsZero() && !e.ResentDate.IsZero() { |
| 305 | t.Errorf("[Test Case %v] Wrong resent date. Expected: %v, Got: %v", index, td.resentDate, e.ResentDate) |
| 306 | } |
| 307 | |
| 308 | d = dereferenceAddressList(e.ResentFrom) |
| 309 | if !assertAddressListEq(td.resentFrom, d) { |
| 310 | t.Errorf("[Test Case %v] Wrong resent from. Expected: %s, Got: %s", index, td.resentFrom, d) |
| 311 | } |
| 312 | |
| 313 | var resentSender mail.Address |
| 314 | if e.ResentSender != nil { |
| 315 | resentSender = *e.ResentSender |
| 316 | } |
| 317 | if td.resentSender != resentSender { |
| 318 | t.Errorf("[Test Case %v] Wrong resent sender. Expected: %s, Got: %s", index, td.resentSender, resentSender) |
| 319 | } |
| 320 | |
| 321 | d = dereferenceAddressList(e.ResentTo) |
| 322 | if !assertAddressListEq(td.resentTo, d) { |
| 323 | t.Errorf("[Test Case %v] Wrong resent to. Expected: %s, Got: %s", index, td.resentTo, d) |
| 324 | } |
| 325 | |
| 326 | d = dereferenceAddressList(e.ResentCc) |
| 327 | if !assertAddressListEq(td.resentCc, d) { |
| 328 | t.Errorf("[Test Case %v] Wrong resent cc. Expected: %s, Got: %s", index, td.resentCc, d) |
| 329 | } |
| 330 | |
| 331 | d = dereferenceAddressList(e.ResentBcc) |
| 332 | if !assertAddressListEq(td.resentBcc, d) { |
| 333 | t.Errorf("[Test Case %v] Wrong resent bcc. Expected: %s, Got: %s", index, td.resentBcc, d) |
| 334 | } |
| 335 | |
| 336 | if !assertSliceEq(td.inReplyTo, e.InReplyTo) { |
| 337 | t.Errorf("[Test Case %v] Wrong in reply to. Expected: %s, Got: %s", index, td.inReplyTo, e.InReplyTo) |
| 338 | } |
| 339 | |
| 340 | if !assertSliceEq(td.references, e.References) { |
| 341 | t.Errorf("[Test Case %v] Wrong references. Expected: %s, Got: %s", index, td.references, e.References) |
| 342 | } |
| 343 | |
| 344 | d = dereferenceAddressList(e.ReplyTo) |
| 345 | if !assertAddressListEq(td.replyTo, d) { |
| 346 | t.Errorf("[Test Case %v] Wrong reply to. Expected: %s, Got: %s", index, td.replyTo, d) |
Dusan Kasan | 17e497e | 2017-04-10 22:44:22 +0200 | [diff] [blame] | 347 | } |
| 348 | |
| 349 | if td.htmlBody != e.HTMLBody { |
Dusan Kasan | b49ceb6 | 2017-04-13 00:00:36 +0200 | [diff] [blame] | 350 | t.Errorf("[Test Case %v] Wrong html body. Expected: '%s', Got: '%s'", index, td.htmlBody, e.HTMLBody) |
Dusan Kasan | 17e497e | 2017-04-10 22:44:22 +0200 | [diff] [blame] | 351 | } |
| 352 | |
| 353 | if td.textBody != e.TextBody { |
Dusan Kasan | b49ceb6 | 2017-04-13 00:00:36 +0200 | [diff] [blame] | 354 | t.Errorf("[Test Case %v] Wrong text body. Expected: '%s', Got: '%s'", index, td.textBody, e.TextBody) |
Dusan Kasan | 17e497e | 2017-04-10 22:44:22 +0200 | [diff] [blame] | 355 | } |
| 356 | |
Dusan Kasan | 17e497e | 2017-04-10 22:44:22 +0200 | [diff] [blame] | 357 | if len(td.attachments) != len(e.Attachments) { |
Dusan Kasan | b49ceb6 | 2017-04-13 00:00:36 +0200 | [diff] [blame] | 358 | t.Errorf("[Test Case %v] Incorrect number of attachments! Expected: %v, Got: %v.", index, len(td.attachments), len(e.Attachments)) |
Dusan Kasan | 17e497e | 2017-04-10 22:44:22 +0200 | [diff] [blame] | 359 | } else { |
| 360 | attachs := e.Attachments[:] |
| 361 | |
Dusan Kasan | 4595dfe | 2017-04-13 00:38:24 +0200 | [diff] [blame] | 362 | for _, ad := range td.attachments { |
Dusan Kasan | 17e497e | 2017-04-10 22:44:22 +0200 | [diff] [blame] | 363 | found := false |
| 364 | |
Dusan Kasan | 4595dfe | 2017-04-13 00:38:24 +0200 | [diff] [blame] | 365 | for i, ra := range attachs { |
Dusan Kasan | 17e497e | 2017-04-10 22:44:22 +0200 | [diff] [blame] | 366 | b, err := ioutil.ReadAll(ra.Data) |
| 367 | if err != nil { |
| 368 | t.Error(err) |
| 369 | } |
| 370 | |
| 371 | encoded := base64.StdEncoding.EncodeToString(b) |
Dusan Kasan | b49ceb6 | 2017-04-13 00:00:36 +0200 | [diff] [blame] | 372 | if ra.Filename == ad.filename && encoded == ad.base64data && ra.ContentType == ad.contentType { |
Dusan Kasan | 17e497e | 2017-04-10 22:44:22 +0200 | [diff] [blame] | 373 | found = true |
| 374 | attachs = append(attachs[:i], attachs[i+1:]...) |
| 375 | } |
| 376 | } |
| 377 | |
| 378 | if !found { |
Dusan Kasan | b49ceb6 | 2017-04-13 00:00:36 +0200 | [diff] [blame] | 379 | t.Errorf("[Test Case %v] Attachment not found: %s", index, ad.filename) |
Dusan Kasan | 17e497e | 2017-04-10 22:44:22 +0200 | [diff] [blame] | 380 | } |
| 381 | } |
| 382 | |
| 383 | if len(attachs) != 0 { |
Dusan Kasan | b49ceb6 | 2017-04-13 00:00:36 +0200 | [diff] [blame] | 384 | t.Errorf("[Test Case %v] Email contains %v unexpected attachments: %v", index, len(attachs), attachs) |
Dusan Kasan | 17e497e | 2017-04-10 22:44:22 +0200 | [diff] [blame] | 385 | } |
| 386 | } |
| 387 | |
| 388 | if len(td.embeddedFiles) != len(e.EmbeddedFiles) { |
Dusan Kasan | 1a96648 | 2017-04-18 10:45:25 +0200 | [diff] [blame] | 389 | t.Errorf("[Test Case %v] Incorrect number of embedded files! Expected: %v, Got: %v.", index, len(td.embeddedFiles), len(e.EmbeddedFiles)) |
Dusan Kasan | 17e497e | 2017-04-10 22:44:22 +0200 | [diff] [blame] | 390 | } else { |
| 391 | embeds := e.EmbeddedFiles[:] |
| 392 | |
Dusan Kasan | 4595dfe | 2017-04-13 00:38:24 +0200 | [diff] [blame] | 393 | for _, ad := range td.embeddedFiles { |
Dusan Kasan | 17e497e | 2017-04-10 22:44:22 +0200 | [diff] [blame] | 394 | found := false |
| 395 | |
Dusan Kasan | 4595dfe | 2017-04-13 00:38:24 +0200 | [diff] [blame] | 396 | for i, ra := range embeds { |
Dusan Kasan | 17e497e | 2017-04-10 22:44:22 +0200 | [diff] [blame] | 397 | b, err := ioutil.ReadAll(ra.Data) |
| 398 | if err != nil { |
| 399 | t.Error(err) |
| 400 | } |
| 401 | |
| 402 | encoded := base64.StdEncoding.EncodeToString(b) |
| 403 | |
Dusan Kasan | b49ceb6 | 2017-04-13 00:00:36 +0200 | [diff] [blame] | 404 | if ra.CID == ad.cid && encoded == ad.base64data && ra.ContentType == ad.contentType { |
Dusan Kasan | 17e497e | 2017-04-10 22:44:22 +0200 | [diff] [blame] | 405 | found = true |
| 406 | embeds = append(embeds[:i], embeds[i+1:]...) |
| 407 | } |
| 408 | } |
| 409 | |
| 410 | if !found { |
Dusan Kasan | b49ceb6 | 2017-04-13 00:00:36 +0200 | [diff] [blame] | 411 | t.Errorf("[Test Case %v] Embedded file not found: %s", index, ad.cid) |
Dusan Kasan | 17e497e | 2017-04-10 22:44:22 +0200 | [diff] [blame] | 412 | } |
| 413 | } |
| 414 | |
| 415 | if len(embeds) != 0 { |
Dusan Kasan | b49ceb6 | 2017-04-13 00:00:36 +0200 | [diff] [blame] | 416 | t.Errorf("[Test Case %v] Email contains %v unexpected embedded files: %v", index, len(embeds), embeds) |
Dusan Kasan | 17e497e | 2017-04-10 22:44:22 +0200 | [diff] [blame] | 417 | } |
| 418 | } |
| 419 | } |
| 420 | } |
| 421 | |
| 422 | func parseDate(in string) time.Time { |
| 423 | out, err := time.Parse(time.RFC1123Z, in) |
| 424 | if err != nil { |
| 425 | panic(err) |
| 426 | } |
| 427 | |
| 428 | return out |
| 429 | } |
| 430 | |
Dusan Kasan | 4595dfe | 2017-04-13 00:38:24 +0200 | [diff] [blame] | 431 | type attachmentData struct { |
| 432 | filename string |
Dusan Kasan | b49ceb6 | 2017-04-13 00:00:36 +0200 | [diff] [blame] | 433 | contentType string |
Dusan Kasan | 4595dfe | 2017-04-13 00:38:24 +0200 | [diff] [blame] | 434 | base64data string |
Dusan Kasan | 17e497e | 2017-04-10 22:44:22 +0200 | [diff] [blame] | 435 | } |
| 436 | |
Dusan Kasan | 4595dfe | 2017-04-13 00:38:24 +0200 | [diff] [blame] | 437 | type embeddedFileData struct { |
| 438 | cid string |
Dusan Kasan | b49ceb6 | 2017-04-13 00:00:36 +0200 | [diff] [blame] | 439 | contentType string |
Dusan Kasan | 4595dfe | 2017-04-13 00:38:24 +0200 | [diff] [blame] | 440 | base64data string |
Dusan Kasan | 17e497e | 2017-04-10 22:44:22 +0200 | [diff] [blame] | 441 | } |
| 442 | |
| 443 | func assertSliceEq(a, b []string) bool { |
| 444 | if len(a) == len(b) && len(a) == 0 { |
| 445 | return true |
| 446 | } |
| 447 | |
| 448 | if a == nil && b == nil { |
Dusan Kasan | 4595dfe | 2017-04-13 00:38:24 +0200 | [diff] [blame] | 449 | return true |
Dusan Kasan | 17e497e | 2017-04-10 22:44:22 +0200 | [diff] [blame] | 450 | } |
| 451 | |
| 452 | if a == nil || b == nil { |
Dusan Kasan | 4595dfe | 2017-04-13 00:38:24 +0200 | [diff] [blame] | 453 | return false |
Dusan Kasan | 17e497e | 2017-04-10 22:44:22 +0200 | [diff] [blame] | 454 | } |
| 455 | |
| 456 | if len(a) != len(b) { |
| 457 | return false |
| 458 | } |
| 459 | |
| 460 | for i := range a { |
| 461 | if a[i] != b[i] { |
| 462 | return false |
| 463 | } |
| 464 | } |
| 465 | |
| 466 | return true |
| 467 | } |
| 468 | |
Dusan Kasan | b49ceb6 | 2017-04-13 00:00:36 +0200 | [diff] [blame] | 469 | func assertAddressListEq(a, b []mail.Address) bool { |
| 470 | if len(a) == len(b) && len(a) == 0 { |
| 471 | return true |
| 472 | } |
| 473 | |
| 474 | if a == nil && b == nil { |
Dusan Kasan | 4595dfe | 2017-04-13 00:38:24 +0200 | [diff] [blame] | 475 | return true |
Dusan Kasan | b49ceb6 | 2017-04-13 00:00:36 +0200 | [diff] [blame] | 476 | } |
| 477 | |
| 478 | if a == nil || b == nil { |
Dusan Kasan | 4595dfe | 2017-04-13 00:38:24 +0200 | [diff] [blame] | 479 | return false |
Dusan Kasan | b49ceb6 | 2017-04-13 00:00:36 +0200 | [diff] [blame] | 480 | } |
| 481 | |
| 482 | if len(a) != len(b) { |
| 483 | return false |
| 484 | } |
| 485 | |
| 486 | for i := range a { |
| 487 | if a[i] != b[i] { |
| 488 | return false |
| 489 | } |
| 490 | } |
| 491 | |
| 492 | return true |
| 493 | } |
| 494 | |
| 495 | func dereferenceAddressList(al []*mail.Address) (result []mail.Address) { |
Dusan Kasan | 4595dfe | 2017-04-13 00:38:24 +0200 | [diff] [blame] | 496 | for _, a := range al { |
Dusan Kasan | b49ceb6 | 2017-04-13 00:00:36 +0200 | [diff] [blame] | 497 | result = append(result, *a) |
| 498 | } |
| 499 | |
| 500 | return |
| 501 | } |
| 502 | |
Dusan Kasan | 45ca264 | 2017-04-18 10:39:35 +0200 | [diff] [blame] | 503 | var data1 = `From: =?UTF-8?Q?Peter_Pahol=C3=ADk?= <peter.paholik@gmail.com> |
Dusan Kasan | 17e497e | 2017-04-10 22:44:22 +0200 | [diff] [blame] | 504 | Date: Fri, 7 Apr 2017 09:17:26 +0200 |
| 505 | Message-ID: <CACtgX4kNXE7T5XKSKeH_zEcfUUmf2vXVASxYjaaK9cCn-3zb_g@mail.gmail.com> |
Dusan Kasan | f4376a6 | 2017-05-23 21:03:55 +0200 | [diff] [blame] | 506 | Subject: =?UTF-8?Q?Peter_Pahol=C3=ADk?= |
Dusan Kasan | 17e497e | 2017-04-10 22:44:22 +0200 | [diff] [blame] | 507 | To: dusan@kasan.sk |
| 508 | Content-Type: multipart/mixed; boundary=f403045f1dcc043a44054c8e6bbf |
| 509 | |
| 510 | --f403045f1dcc043a44054c8e6bbf |
| 511 | Content-Type: multipart/alternative; boundary=f403045f1dcc043a3f054c8e6bbd |
| 512 | |
| 513 | --f403045f1dcc043a3f054c8e6bbd |
| 514 | Content-Type: text/plain; charset=UTF-8 |
| 515 | |
| 516 | |
| 517 | |
| 518 | --f403045f1dcc043a3f054c8e6bbd |
| 519 | Content-Type: text/html; charset=UTF-8 |
| 520 | |
| 521 | <div dir="ltr"><br></div> |
| 522 | |
| 523 | --f403045f1dcc043a3f054c8e6bbd-- |
| 524 | --f403045f1dcc043a44054c8e6bbf |
| 525 | Content-Type: application/pdf; |
| 526 | name="=?UTF-8?Q?Peter_Paholi=CC=81k_1?= |
| 527 | =?UTF-8?Q?_4_2017_2017=2D04=2D07=2Epdf?=" |
| 528 | Content-Disposition: attachment; |
| 529 | filename="=?UTF-8?Q?Peter_Paholi=CC=81k_1?= |
| 530 | =?UTF-8?Q?_4_2017_2017=2D04=2D07=2Epdf?=" |
| 531 | Content-Transfer-Encoding: base64 |
| 532 | X-Attachment-Id: f_j17i0f0d0 |
| 533 | |
| 534 | JVBERi0xLjQNCiW1tbW1DQoxIDAgb2JqDQo8PC9UeXBlL0NhdGFsb2cvUGFnZXMgMiAwIFIvTGFu |
| 535 | Zyhlbi1VUykgL1N0cnVjdFRyZWVSb290IDY3IDAgUi9NYXJrSW5mbzw8L01hcmtlZCB0cnVlPj4v |
| 536 | T3V0cHV0SW50ZW50c1s8PC9UeXBlL091dHB1dEludGVudC9TL0dUU19QREZBMS9PdXRwdXRDb25k |
| 537 | ZXYgMzk1MzYyDQo+Pg0Kc3RhcnR4cmVmDQo0MTk4ODUNCiUlRU9GDQo= |
| 538 | --f403045f1dcc043a44054c8e6bbf-- |
| 539 | ` |
| 540 | |
Dusan Kasan | 45ca264 | 2017-04-18 10:39:35 +0200 | [diff] [blame] | 541 | var data2 = `Subject: Re: Test Subject 2 |
Dusan Kasan | 17e497e | 2017-04-10 22:44:22 +0200 | [diff] [blame] | 542 | To: info@receiver.com |
| 543 | References: <2f6b7595-c01e-46e5-42bc-f263e1c4282d@receiver.com> |
| 544 | <9ff38d03-c4ab-89b7-9328-e99d5e24e3ba@domain.com> |
| 545 | Cc: Cc Man <ccman@gmail.com> |
| 546 | From: Sender Man <sender@domain.com> |
| 547 | Message-ID: <0e9a21b4-01dc-e5c1-dcd6-58ce5aa61f4f@receiver.com> |
| 548 | Date: Fri, 7 Apr 2017 12:59:55 +0200 |
| 549 | User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:45.0) |
| 550 | Gecko/20100101 Thunderbird/45.8.0 |
| 551 | MIME-Version: 1.0 |
| 552 | In-Reply-To: <9ff38d03-c4ab-89b7-9328-e99d5e24e3ba@receiver.eu> |
| 553 | Content-Type: multipart/alternative; |
| 554 | boundary="------------C70C0458A558E585ACB75FB4" |
| 555 | |
| 556 | This is a multi-part message in MIME format. |
| 557 | --------------C70C0458A558E585ACB75FB4 |
| 558 | Content-Type: text/plain; charset=utf-8; format=flowed |
| 559 | Content-Transfer-Encoding: 8bit |
| 560 | |
| 561 | First level |
| 562 | > Second level |
| 563 | >> Third level |
| 564 | > |
| 565 | |
| 566 | |
| 567 | --------------C70C0458A558E585ACB75FB4 |
| 568 | Content-Type: multipart/related; |
| 569 | boundary="------------5DB4A1356834BB602A5F88B2" |
| 570 | |
| 571 | |
| 572 | --------------5DB4A1356834BB602A5F88B2 |
| 573 | Content-Type: text/html; charset=utf-8 |
| 574 | Content-Transfer-Encoding: 8bit |
| 575 | |
| 576 | <html>data<img src="part2.9599C449.04E5EC81@develhell.com"/></html> |
| 577 | |
| 578 | --------------5DB4A1356834BB602A5F88B2 |
| 579 | Content-Type: image/png |
| 580 | Content-Transfer-Encoding: base64 |
| 581 | Content-ID: <part2.9599C449.04E5EC81@develhell.com> |
| 582 | |
| 583 | iVBORw0KGgoAAAANSUhEUgAAAQEAAAAYCAIAAAB1IN9NAAAACXBIWXMAAAsTAAALEwEAmpwY |
| 584 | YKUKF+Os3baUndC0pDnwNAmLy1SUr2Gw0luxQuV/AwC6cEhVV5VRrwAAAABJRU5ErkJggg== |
| 585 | --------------5DB4A1356834BB602A5F88B2 |
| 586 | |
| 587 | --------------C70C0458A558E585ACB75FB4-- |
Dusan Kasan | b49ceb6 | 2017-04-13 00:00:36 +0200 | [diff] [blame] | 588 | ` |
| 589 | |
Dusan Kasan | 45ca264 | 2017-04-18 10:39:35 +0200 | [diff] [blame] | 590 | var rfc5322exampleA11 = `From: John Doe <jdoe@machine.example> |
Dusan Kasan | b49ceb6 | 2017-04-13 00:00:36 +0200 | [diff] [blame] | 591 | Sender: Michael Jones <mjones@machine.example> |
| 592 | To: Mary Smith <mary@example.net> |
| 593 | Subject: Saying Hello |
| 594 | Date: Fri, 21 Nov 1997 09:55:06 -0600 |
| 595 | Message-ID: <1234@local.machine.example> |
| 596 | |
| 597 | This is a message just to say hello. |
| 598 | So, "Hello". |
| 599 | ` |
| 600 | |
Dusan Kasan | 45ca264 | 2017-04-18 10:39:35 +0200 | [diff] [blame] | 601 | var rfc5322exampleA12 = `From: "Joe Q. Public" <john.q.public@example.com> |
Dusan Kasan | b49ceb6 | 2017-04-13 00:00:36 +0200 | [diff] [blame] | 602 | To: Mary Smith <mary@x.test>, jdoe@example.org, Who? <one@y.test> |
| 603 | Cc: <boss@nil.test>, "Giant; \"Big\" Box" <sysservices@example.net> |
| 604 | Date: Tue, 1 Jul 2003 10:52:37 +0200 |
| 605 | Message-ID: <5678.21-Nov-1997@example.com> |
| 606 | |
| 607 | Hi everyone. |
| 608 | ` |
| 609 | |
| 610 | //todo: not yet implemented in net/mail |
| 611 | //once there is support for this, add it |
Dusan Kasan | 45ca264 | 2017-04-18 10:39:35 +0200 | [diff] [blame] | 612 | var rfc5322exampleA13 = `From: Pete <pete@silly.example> |
Dusan Kasan | b49ceb6 | 2017-04-13 00:00:36 +0200 | [diff] [blame] | 613 | To: A Group:Ed Jones <c@a.test>,joe@where.test,John <jdoe@one.test>; |
| 614 | Cc: Undisclosed recipients:; |
| 615 | Date: Thu, 13 Feb 1969 23:32:54 -0330 |
| 616 | Message-ID: <testabcd.1234@silly.example> |
| 617 | |
| 618 | Testing. |
| 619 | ` |
| 620 | |
| 621 | //we skipped the first message bcause it's the same as A 1.1 |
Dusan Kasan | 45ca264 | 2017-04-18 10:39:35 +0200 | [diff] [blame] | 622 | var rfc5322exampleA2a = `From: Mary Smith <mary@example.net> |
Dusan Kasan | b49ceb6 | 2017-04-13 00:00:36 +0200 | [diff] [blame] | 623 | To: John Doe <jdoe@machine.example> |
| 624 | Reply-To: "Mary Smith: Personal Account" <smith@home.example> |
| 625 | Subject: Re: Saying Hello |
| 626 | Date: Fri, 21 Nov 1997 10:01:10 -0600 |
| 627 | Message-ID: <3456@example.net> |
| 628 | In-Reply-To: <1234@local.machine.example> |
| 629 | References: <1234@local.machine.example> |
| 630 | |
| 631 | This is a reply to your hello. |
| 632 | ` |
| 633 | |
Dusan Kasan | 45ca264 | 2017-04-18 10:39:35 +0200 | [diff] [blame] | 634 | var rfc5322exampleA2b = `To: "Mary Smith: Personal Account" <smith@home.example> |
Dusan Kasan | b49ceb6 | 2017-04-13 00:00:36 +0200 | [diff] [blame] | 635 | From: John Doe <jdoe@machine.example> |
| 636 | Subject: Re: Saying Hello |
| 637 | Date: Fri, 21 Nov 1997 11:00:00 -0600 |
| 638 | Message-ID: <abcd.1234@local.machine.test> |
| 639 | In-Reply-To: <3456@example.net> |
| 640 | References: <1234@local.machine.example> <3456@example.net> |
| 641 | |
| 642 | This is a reply to your reply. |
| 643 | ` |
| 644 | |
Dusan Kasan | 45ca264 | 2017-04-18 10:39:35 +0200 | [diff] [blame] | 645 | var rfc5322exampleA3 = `Resent-From: Mary Smith <mary@example.net> |
Dusan Kasan | b49ceb6 | 2017-04-13 00:00:36 +0200 | [diff] [blame] | 646 | Resent-To: Jane Brown <j-brown@other.example> |
| 647 | Resent-Date: Mon, 24 Nov 1997 14:22:01 -0800 |
| 648 | Resent-Message-ID: <78910@example.net> |
| 649 | From: John Doe <jdoe@machine.example> |
| 650 | To: Mary Smith <mary@example.net> |
| 651 | Subject: Saying Hello |
| 652 | Date: Fri, 21 Nov 1997 09:55:06 -0600 |
| 653 | Message-ID: <1234@local.machine.example> |
| 654 | |
| 655 | This is a message just to say hello. |
| 656 | So, "Hello".` |
| 657 | |
Dusan Kasan | 45ca264 | 2017-04-18 10:39:35 +0200 | [diff] [blame] | 658 | var rfc5322exampleA4 = `Received: from x.y.test |
Dusan Kasan | b49ceb6 | 2017-04-13 00:00:36 +0200 | [diff] [blame] | 659 | by example.net |
| 660 | via TCP |
| 661 | with ESMTP |
| 662 | id ABC12345 |
| 663 | for <mary@example.net>; 21 Nov 1997 10:05:43 -0600 |
| 664 | Received: from node.example by x.y.test; 21 Nov 1997 10:01:22 -0600 |
| 665 | From: John Doe <jdoe@node.example> |
| 666 | To: Mary Smith <mary@example.net> |
| 667 | Subject: Saying Hello |
| 668 | Date: Fri, 21 Nov 1997 09:55:06 -0600 |
| 669 | Message-ID: <1234@local.node.example> |
| 670 | |
| 671 | This is a message just to say hello. |
| 672 | So, "Hello".` |