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 { |
Edwin Love | 0c868a4 | 2019-04-02 11:17:35 +0100 | [diff] [blame^] | 251 | e, err := Parse(strings.NewReader(td.mailData)) |
Dusan Kasan | 17e497e | 2017-04-10 22:44:22 +0200 | [diff] [blame] | 252 | if err != nil { |
| 253 | t.Error(err) |
| 254 | } |
| 255 | |
Dusan Kasan | b49ceb6 | 2017-04-13 00:00:36 +0200 | [diff] [blame] | 256 | if td.subject != e.Subject { |
| 257 | 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] | 258 | } |
| 259 | |
Dusan Kasan | b49ceb6 | 2017-04-13 00:00:36 +0200 | [diff] [blame] | 260 | if td.messageID != e.MessageID { |
| 261 | 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] | 262 | } |
| 263 | |
Dusan Kasan | b49ceb6 | 2017-04-13 00:00:36 +0200 | [diff] [blame] | 264 | if !td.date.Equal(e.Date) { |
| 265 | 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] | 266 | } |
| 267 | |
Dusan Kasan | b49ceb6 | 2017-04-13 00:00:36 +0200 | [diff] [blame] | 268 | d := dereferenceAddressList(e.From) |
| 269 | if !assertAddressListEq(td.from, d) { |
| 270 | 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] | 271 | } |
| 272 | |
Dusan Kasan | b49ceb6 | 2017-04-13 00:00:36 +0200 | [diff] [blame] | 273 | var sender mail.Address |
| 274 | if e.Sender != nil { |
| 275 | sender = *e.Sender |
| 276 | } |
| 277 | if td.sender != sender { |
| 278 | 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] | 279 | } |
| 280 | |
Dusan Kasan | b49ceb6 | 2017-04-13 00:00:36 +0200 | [diff] [blame] | 281 | d = dereferenceAddressList(e.To) |
| 282 | if !assertAddressListEq(td.to, d) { |
| 283 | 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] | 284 | } |
| 285 | |
Dusan Kasan | b49ceb6 | 2017-04-13 00:00:36 +0200 | [diff] [blame] | 286 | d = dereferenceAddressList(e.Cc) |
| 287 | if !assertAddressListEq(td.cc, d) { |
| 288 | 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] | 289 | } |
| 290 | |
Dusan Kasan | b49ceb6 | 2017-04-13 00:00:36 +0200 | [diff] [blame] | 291 | d = dereferenceAddressList(e.Bcc) |
| 292 | if !assertAddressListEq(td.bcc, d) { |
| 293 | 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] | 294 | } |
| 295 | |
Dusan Kasan | b49ceb6 | 2017-04-13 00:00:36 +0200 | [diff] [blame] | 296 | if td.resentMessageID != e.ResentMessageID { |
| 297 | 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] | 298 | } |
| 299 | |
Dusan Kasan | b49ceb6 | 2017-04-13 00:00:36 +0200 | [diff] [blame] | 300 | if !td.resentDate.Equal(e.ResentDate) && !td.resentDate.IsZero() && !e.ResentDate.IsZero() { |
| 301 | t.Errorf("[Test Case %v] Wrong resent date. Expected: %v, Got: %v", index, td.resentDate, e.ResentDate) |
| 302 | } |
| 303 | |
| 304 | d = dereferenceAddressList(e.ResentFrom) |
| 305 | if !assertAddressListEq(td.resentFrom, d) { |
| 306 | t.Errorf("[Test Case %v] Wrong resent from. Expected: %s, Got: %s", index, td.resentFrom, d) |
| 307 | } |
| 308 | |
| 309 | var resentSender mail.Address |
| 310 | if e.ResentSender != nil { |
| 311 | resentSender = *e.ResentSender |
| 312 | } |
| 313 | if td.resentSender != resentSender { |
| 314 | t.Errorf("[Test Case %v] Wrong resent sender. Expected: %s, Got: %s", index, td.resentSender, resentSender) |
| 315 | } |
| 316 | |
| 317 | d = dereferenceAddressList(e.ResentTo) |
| 318 | if !assertAddressListEq(td.resentTo, d) { |
| 319 | t.Errorf("[Test Case %v] Wrong resent to. Expected: %s, Got: %s", index, td.resentTo, d) |
| 320 | } |
| 321 | |
| 322 | d = dereferenceAddressList(e.ResentCc) |
| 323 | if !assertAddressListEq(td.resentCc, d) { |
| 324 | t.Errorf("[Test Case %v] Wrong resent cc. Expected: %s, Got: %s", index, td.resentCc, d) |
| 325 | } |
| 326 | |
| 327 | d = dereferenceAddressList(e.ResentBcc) |
| 328 | if !assertAddressListEq(td.resentBcc, d) { |
| 329 | t.Errorf("[Test Case %v] Wrong resent bcc. Expected: %s, Got: %s", index, td.resentBcc, d) |
| 330 | } |
| 331 | |
| 332 | if !assertSliceEq(td.inReplyTo, e.InReplyTo) { |
| 333 | t.Errorf("[Test Case %v] Wrong in reply to. Expected: %s, Got: %s", index, td.inReplyTo, e.InReplyTo) |
| 334 | } |
| 335 | |
| 336 | if !assertSliceEq(td.references, e.References) { |
| 337 | t.Errorf("[Test Case %v] Wrong references. Expected: %s, Got: %s", index, td.references, e.References) |
| 338 | } |
| 339 | |
| 340 | d = dereferenceAddressList(e.ReplyTo) |
| 341 | if !assertAddressListEq(td.replyTo, d) { |
| 342 | 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] | 343 | } |
| 344 | |
| 345 | if td.htmlBody != e.HTMLBody { |
Dusan Kasan | b49ceb6 | 2017-04-13 00:00:36 +0200 | [diff] [blame] | 346 | 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] | 347 | } |
| 348 | |
| 349 | if td.textBody != e.TextBody { |
Dusan Kasan | b49ceb6 | 2017-04-13 00:00:36 +0200 | [diff] [blame] | 350 | 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] | 351 | } |
| 352 | |
Dusan Kasan | 17e497e | 2017-04-10 22:44:22 +0200 | [diff] [blame] | 353 | if len(td.attachments) != len(e.Attachments) { |
Dusan Kasan | b49ceb6 | 2017-04-13 00:00:36 +0200 | [diff] [blame] | 354 | 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] | 355 | } else { |
| 356 | attachs := e.Attachments[:] |
| 357 | |
Dusan Kasan | 4595dfe | 2017-04-13 00:38:24 +0200 | [diff] [blame] | 358 | for _, ad := range td.attachments { |
Dusan Kasan | 17e497e | 2017-04-10 22:44:22 +0200 | [diff] [blame] | 359 | found := false |
| 360 | |
Dusan Kasan | 4595dfe | 2017-04-13 00:38:24 +0200 | [diff] [blame] | 361 | for i, ra := range attachs { |
Dusan Kasan | 17e497e | 2017-04-10 22:44:22 +0200 | [diff] [blame] | 362 | b, err := ioutil.ReadAll(ra.Data) |
| 363 | if err != nil { |
| 364 | t.Error(err) |
| 365 | } |
| 366 | |
| 367 | encoded := base64.StdEncoding.EncodeToString(b) |
Dusan Kasan | b49ceb6 | 2017-04-13 00:00:36 +0200 | [diff] [blame] | 368 | if ra.Filename == ad.filename && encoded == ad.base64data && ra.ContentType == ad.contentType { |
Dusan Kasan | 17e497e | 2017-04-10 22:44:22 +0200 | [diff] [blame] | 369 | found = true |
| 370 | attachs = append(attachs[:i], attachs[i+1:]...) |
| 371 | } |
| 372 | } |
| 373 | |
| 374 | if !found { |
Dusan Kasan | b49ceb6 | 2017-04-13 00:00:36 +0200 | [diff] [blame] | 375 | t.Errorf("[Test Case %v] Attachment not found: %s", index, ad.filename) |
Dusan Kasan | 17e497e | 2017-04-10 22:44:22 +0200 | [diff] [blame] | 376 | } |
| 377 | } |
| 378 | |
| 379 | if len(attachs) != 0 { |
Dusan Kasan | b49ceb6 | 2017-04-13 00:00:36 +0200 | [diff] [blame] | 380 | 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] | 381 | } |
| 382 | } |
| 383 | |
| 384 | if len(td.embeddedFiles) != len(e.EmbeddedFiles) { |
Dusan Kasan | 1a96648 | 2017-04-18 10:45:25 +0200 | [diff] [blame] | 385 | 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] | 386 | } else { |
| 387 | embeds := e.EmbeddedFiles[:] |
| 388 | |
Dusan Kasan | 4595dfe | 2017-04-13 00:38:24 +0200 | [diff] [blame] | 389 | for _, ad := range td.embeddedFiles { |
Dusan Kasan | 17e497e | 2017-04-10 22:44:22 +0200 | [diff] [blame] | 390 | found := false |
| 391 | |
Dusan Kasan | 4595dfe | 2017-04-13 00:38:24 +0200 | [diff] [blame] | 392 | for i, ra := range embeds { |
Dusan Kasan | 17e497e | 2017-04-10 22:44:22 +0200 | [diff] [blame] | 393 | b, err := ioutil.ReadAll(ra.Data) |
| 394 | if err != nil { |
| 395 | t.Error(err) |
| 396 | } |
| 397 | |
| 398 | encoded := base64.StdEncoding.EncodeToString(b) |
| 399 | |
Dusan Kasan | b49ceb6 | 2017-04-13 00:00:36 +0200 | [diff] [blame] | 400 | if ra.CID == ad.cid && encoded == ad.base64data && ra.ContentType == ad.contentType { |
Dusan Kasan | 17e497e | 2017-04-10 22:44:22 +0200 | [diff] [blame] | 401 | found = true |
| 402 | embeds = append(embeds[:i], embeds[i+1:]...) |
| 403 | } |
| 404 | } |
| 405 | |
| 406 | if !found { |
Dusan Kasan | b49ceb6 | 2017-04-13 00:00:36 +0200 | [diff] [blame] | 407 | 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] | 408 | } |
| 409 | } |
| 410 | |
| 411 | if len(embeds) != 0 { |
Dusan Kasan | b49ceb6 | 2017-04-13 00:00:36 +0200 | [diff] [blame] | 412 | 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] | 413 | } |
| 414 | } |
| 415 | } |
| 416 | } |
| 417 | |
| 418 | func parseDate(in string) time.Time { |
| 419 | out, err := time.Parse(time.RFC1123Z, in) |
| 420 | if err != nil { |
| 421 | panic(err) |
| 422 | } |
| 423 | |
| 424 | return out |
| 425 | } |
| 426 | |
Dusan Kasan | 4595dfe | 2017-04-13 00:38:24 +0200 | [diff] [blame] | 427 | type attachmentData struct { |
| 428 | filename string |
Dusan Kasan | b49ceb6 | 2017-04-13 00:00:36 +0200 | [diff] [blame] | 429 | contentType string |
Dusan Kasan | 4595dfe | 2017-04-13 00:38:24 +0200 | [diff] [blame] | 430 | base64data string |
Dusan Kasan | 17e497e | 2017-04-10 22:44:22 +0200 | [diff] [blame] | 431 | } |
| 432 | |
Dusan Kasan | 4595dfe | 2017-04-13 00:38:24 +0200 | [diff] [blame] | 433 | type embeddedFileData struct { |
| 434 | cid string |
Dusan Kasan | b49ceb6 | 2017-04-13 00:00:36 +0200 | [diff] [blame] | 435 | contentType string |
Dusan Kasan | 4595dfe | 2017-04-13 00:38:24 +0200 | [diff] [blame] | 436 | base64data string |
Dusan Kasan | 17e497e | 2017-04-10 22:44:22 +0200 | [diff] [blame] | 437 | } |
| 438 | |
| 439 | func assertSliceEq(a, b []string) bool { |
| 440 | if len(a) == len(b) && len(a) == 0 { |
| 441 | return true |
| 442 | } |
| 443 | |
| 444 | if a == nil && b == nil { |
Dusan Kasan | 4595dfe | 2017-04-13 00:38:24 +0200 | [diff] [blame] | 445 | return true |
Dusan Kasan | 17e497e | 2017-04-10 22:44:22 +0200 | [diff] [blame] | 446 | } |
| 447 | |
| 448 | if a == nil || b == nil { |
Dusan Kasan | 4595dfe | 2017-04-13 00:38:24 +0200 | [diff] [blame] | 449 | return false |
Dusan Kasan | 17e497e | 2017-04-10 22:44:22 +0200 | [diff] [blame] | 450 | } |
| 451 | |
| 452 | if len(a) != len(b) { |
| 453 | return false |
| 454 | } |
| 455 | |
| 456 | for i := range a { |
| 457 | if a[i] != b[i] { |
| 458 | return false |
| 459 | } |
| 460 | } |
| 461 | |
| 462 | return true |
| 463 | } |
| 464 | |
Dusan Kasan | b49ceb6 | 2017-04-13 00:00:36 +0200 | [diff] [blame] | 465 | func assertAddressListEq(a, b []mail.Address) bool { |
| 466 | if len(a) == len(b) && len(a) == 0 { |
| 467 | return true |
| 468 | } |
| 469 | |
| 470 | if a == nil && b == nil { |
Dusan Kasan | 4595dfe | 2017-04-13 00:38:24 +0200 | [diff] [blame] | 471 | return true |
Dusan Kasan | b49ceb6 | 2017-04-13 00:00:36 +0200 | [diff] [blame] | 472 | } |
| 473 | |
| 474 | if a == nil || b == nil { |
Dusan Kasan | 4595dfe | 2017-04-13 00:38:24 +0200 | [diff] [blame] | 475 | return false |
Dusan Kasan | b49ceb6 | 2017-04-13 00:00:36 +0200 | [diff] [blame] | 476 | } |
| 477 | |
| 478 | if len(a) != len(b) { |
| 479 | return false |
| 480 | } |
| 481 | |
| 482 | for i := range a { |
| 483 | if a[i] != b[i] { |
| 484 | return false |
| 485 | } |
| 486 | } |
| 487 | |
| 488 | return true |
| 489 | } |
| 490 | |
| 491 | func dereferenceAddressList(al []*mail.Address) (result []mail.Address) { |
Dusan Kasan | 4595dfe | 2017-04-13 00:38:24 +0200 | [diff] [blame] | 492 | for _, a := range al { |
Dusan Kasan | b49ceb6 | 2017-04-13 00:00:36 +0200 | [diff] [blame] | 493 | result = append(result, *a) |
| 494 | } |
| 495 | |
| 496 | return |
| 497 | } |
| 498 | |
Dusan Kasan | 45ca264 | 2017-04-18 10:39:35 +0200 | [diff] [blame] | 499 | 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] | 500 | Date: Fri, 7 Apr 2017 09:17:26 +0200 |
| 501 | Message-ID: <CACtgX4kNXE7T5XKSKeH_zEcfUUmf2vXVASxYjaaK9cCn-3zb_g@mail.gmail.com> |
Dusan Kasan | f4376a6 | 2017-05-23 21:03:55 +0200 | [diff] [blame] | 502 | Subject: =?UTF-8?Q?Peter_Pahol=C3=ADk?= |
Dusan Kasan | 17e497e | 2017-04-10 22:44:22 +0200 | [diff] [blame] | 503 | To: dusan@kasan.sk |
| 504 | Content-Type: multipart/mixed; boundary=f403045f1dcc043a44054c8e6bbf |
| 505 | |
| 506 | --f403045f1dcc043a44054c8e6bbf |
| 507 | Content-Type: multipart/alternative; boundary=f403045f1dcc043a3f054c8e6bbd |
| 508 | |
| 509 | --f403045f1dcc043a3f054c8e6bbd |
| 510 | Content-Type: text/plain; charset=UTF-8 |
| 511 | |
| 512 | |
| 513 | |
| 514 | --f403045f1dcc043a3f054c8e6bbd |
| 515 | Content-Type: text/html; charset=UTF-8 |
| 516 | |
| 517 | <div dir="ltr"><br></div> |
| 518 | |
| 519 | --f403045f1dcc043a3f054c8e6bbd-- |
| 520 | --f403045f1dcc043a44054c8e6bbf |
| 521 | Content-Type: application/pdf; |
| 522 | name="=?UTF-8?Q?Peter_Paholi=CC=81k_1?= |
| 523 | =?UTF-8?Q?_4_2017_2017=2D04=2D07=2Epdf?=" |
| 524 | Content-Disposition: attachment; |
| 525 | filename="=?UTF-8?Q?Peter_Paholi=CC=81k_1?= |
| 526 | =?UTF-8?Q?_4_2017_2017=2D04=2D07=2Epdf?=" |
| 527 | Content-Transfer-Encoding: base64 |
| 528 | X-Attachment-Id: f_j17i0f0d0 |
| 529 | |
| 530 | JVBERi0xLjQNCiW1tbW1DQoxIDAgb2JqDQo8PC9UeXBlL0NhdGFsb2cvUGFnZXMgMiAwIFIvTGFu |
| 531 | Zyhlbi1VUykgL1N0cnVjdFRyZWVSb290IDY3IDAgUi9NYXJrSW5mbzw8L01hcmtlZCB0cnVlPj4v |
| 532 | T3V0cHV0SW50ZW50c1s8PC9UeXBlL091dHB1dEludGVudC9TL0dUU19QREZBMS9PdXRwdXRDb25k |
| 533 | ZXYgMzk1MzYyDQo+Pg0Kc3RhcnR4cmVmDQo0MTk4ODUNCiUlRU9GDQo= |
| 534 | --f403045f1dcc043a44054c8e6bbf-- |
| 535 | ` |
| 536 | |
Dusan Kasan | 45ca264 | 2017-04-18 10:39:35 +0200 | [diff] [blame] | 537 | var data2 = `Subject: Re: Test Subject 2 |
Dusan Kasan | 17e497e | 2017-04-10 22:44:22 +0200 | [diff] [blame] | 538 | To: info@receiver.com |
| 539 | References: <2f6b7595-c01e-46e5-42bc-f263e1c4282d@receiver.com> |
| 540 | <9ff38d03-c4ab-89b7-9328-e99d5e24e3ba@domain.com> |
| 541 | Cc: Cc Man <ccman@gmail.com> |
| 542 | From: Sender Man <sender@domain.com> |
| 543 | Message-ID: <0e9a21b4-01dc-e5c1-dcd6-58ce5aa61f4f@receiver.com> |
| 544 | Date: Fri, 7 Apr 2017 12:59:55 +0200 |
| 545 | User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:45.0) |
| 546 | Gecko/20100101 Thunderbird/45.8.0 |
| 547 | MIME-Version: 1.0 |
| 548 | In-Reply-To: <9ff38d03-c4ab-89b7-9328-e99d5e24e3ba@receiver.eu> |
| 549 | Content-Type: multipart/alternative; |
| 550 | boundary="------------C70C0458A558E585ACB75FB4" |
| 551 | |
| 552 | This is a multi-part message in MIME format. |
| 553 | --------------C70C0458A558E585ACB75FB4 |
| 554 | Content-Type: text/plain; charset=utf-8; format=flowed |
| 555 | Content-Transfer-Encoding: 8bit |
| 556 | |
| 557 | First level |
| 558 | > Second level |
| 559 | >> Third level |
| 560 | > |
| 561 | |
| 562 | |
| 563 | --------------C70C0458A558E585ACB75FB4 |
| 564 | Content-Type: multipart/related; |
| 565 | boundary="------------5DB4A1356834BB602A5F88B2" |
| 566 | |
| 567 | |
| 568 | --------------5DB4A1356834BB602A5F88B2 |
| 569 | Content-Type: text/html; charset=utf-8 |
| 570 | Content-Transfer-Encoding: 8bit |
| 571 | |
| 572 | <html>data<img src="part2.9599C449.04E5EC81@develhell.com"/></html> |
| 573 | |
| 574 | --------------5DB4A1356834BB602A5F88B2 |
| 575 | Content-Type: image/png |
| 576 | Content-Transfer-Encoding: base64 |
| 577 | Content-ID: <part2.9599C449.04E5EC81@develhell.com> |
| 578 | |
| 579 | iVBORw0KGgoAAAANSUhEUgAAAQEAAAAYCAIAAAB1IN9NAAAACXBIWXMAAAsTAAALEwEAmpwY |
| 580 | YKUKF+Os3baUndC0pDnwNAmLy1SUr2Gw0luxQuV/AwC6cEhVV5VRrwAAAABJRU5ErkJggg== |
| 581 | --------------5DB4A1356834BB602A5F88B2 |
| 582 | |
| 583 | --------------C70C0458A558E585ACB75FB4-- |
Dusan Kasan | b49ceb6 | 2017-04-13 00:00:36 +0200 | [diff] [blame] | 584 | ` |
| 585 | |
Dusan Kasan | 45ca264 | 2017-04-18 10:39:35 +0200 | [diff] [blame] | 586 | var rfc5322exampleA11 = `From: John Doe <jdoe@machine.example> |
Dusan Kasan | b49ceb6 | 2017-04-13 00:00:36 +0200 | [diff] [blame] | 587 | Sender: Michael Jones <mjones@machine.example> |
| 588 | To: Mary Smith <mary@example.net> |
| 589 | Subject: Saying Hello |
| 590 | Date: Fri, 21 Nov 1997 09:55:06 -0600 |
| 591 | Message-ID: <1234@local.machine.example> |
| 592 | |
| 593 | This is a message just to say hello. |
| 594 | So, "Hello". |
| 595 | ` |
| 596 | |
Dusan Kasan | 45ca264 | 2017-04-18 10:39:35 +0200 | [diff] [blame] | 597 | var rfc5322exampleA12 = `From: "Joe Q. Public" <john.q.public@example.com> |
Dusan Kasan | b49ceb6 | 2017-04-13 00:00:36 +0200 | [diff] [blame] | 598 | To: Mary Smith <mary@x.test>, jdoe@example.org, Who? <one@y.test> |
| 599 | Cc: <boss@nil.test>, "Giant; \"Big\" Box" <sysservices@example.net> |
| 600 | Date: Tue, 1 Jul 2003 10:52:37 +0200 |
| 601 | Message-ID: <5678.21-Nov-1997@example.com> |
| 602 | |
| 603 | Hi everyone. |
| 604 | ` |
| 605 | |
| 606 | //todo: not yet implemented in net/mail |
| 607 | //once there is support for this, add it |
Dusan Kasan | 45ca264 | 2017-04-18 10:39:35 +0200 | [diff] [blame] | 608 | var rfc5322exampleA13 = `From: Pete <pete@silly.example> |
Dusan Kasan | b49ceb6 | 2017-04-13 00:00:36 +0200 | [diff] [blame] | 609 | To: A Group:Ed Jones <c@a.test>,joe@where.test,John <jdoe@one.test>; |
| 610 | Cc: Undisclosed recipients:; |
| 611 | Date: Thu, 13 Feb 1969 23:32:54 -0330 |
| 612 | Message-ID: <testabcd.1234@silly.example> |
| 613 | |
| 614 | Testing. |
| 615 | ` |
| 616 | |
| 617 | //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] | 618 | var rfc5322exampleA2a = `From: Mary Smith <mary@example.net> |
Dusan Kasan | b49ceb6 | 2017-04-13 00:00:36 +0200 | [diff] [blame] | 619 | To: John Doe <jdoe@machine.example> |
| 620 | Reply-To: "Mary Smith: Personal Account" <smith@home.example> |
| 621 | Subject: Re: Saying Hello |
| 622 | Date: Fri, 21 Nov 1997 10:01:10 -0600 |
| 623 | Message-ID: <3456@example.net> |
| 624 | In-Reply-To: <1234@local.machine.example> |
| 625 | References: <1234@local.machine.example> |
| 626 | |
| 627 | This is a reply to your hello. |
| 628 | ` |
| 629 | |
Dusan Kasan | 45ca264 | 2017-04-18 10:39:35 +0200 | [diff] [blame] | 630 | var rfc5322exampleA2b = `To: "Mary Smith: Personal Account" <smith@home.example> |
Dusan Kasan | b49ceb6 | 2017-04-13 00:00:36 +0200 | [diff] [blame] | 631 | From: John Doe <jdoe@machine.example> |
| 632 | Subject: Re: Saying Hello |
| 633 | Date: Fri, 21 Nov 1997 11:00:00 -0600 |
| 634 | Message-ID: <abcd.1234@local.machine.test> |
| 635 | In-Reply-To: <3456@example.net> |
| 636 | References: <1234@local.machine.example> <3456@example.net> |
| 637 | |
| 638 | This is a reply to your reply. |
| 639 | ` |
| 640 | |
Dusan Kasan | 45ca264 | 2017-04-18 10:39:35 +0200 | [diff] [blame] | 641 | var rfc5322exampleA3 = `Resent-From: Mary Smith <mary@example.net> |
Dusan Kasan | b49ceb6 | 2017-04-13 00:00:36 +0200 | [diff] [blame] | 642 | Resent-To: Jane Brown <j-brown@other.example> |
| 643 | Resent-Date: Mon, 24 Nov 1997 14:22:01 -0800 |
| 644 | Resent-Message-ID: <78910@example.net> |
| 645 | From: John Doe <jdoe@machine.example> |
| 646 | To: Mary Smith <mary@example.net> |
| 647 | Subject: Saying Hello |
| 648 | Date: Fri, 21 Nov 1997 09:55:06 -0600 |
| 649 | Message-ID: <1234@local.machine.example> |
| 650 | |
| 651 | This is a message just to say hello. |
| 652 | So, "Hello".` |
| 653 | |
Dusan Kasan | 45ca264 | 2017-04-18 10:39:35 +0200 | [diff] [blame] | 654 | var rfc5322exampleA4 = `Received: from x.y.test |
Dusan Kasan | b49ceb6 | 2017-04-13 00:00:36 +0200 | [diff] [blame] | 655 | by example.net |
| 656 | via TCP |
| 657 | with ESMTP |
| 658 | id ABC12345 |
| 659 | for <mary@example.net>; 21 Nov 1997 10:05:43 -0600 |
| 660 | Received: from node.example by x.y.test; 21 Nov 1997 10:01:22 -0600 |
| 661 | From: John Doe <jdoe@node.example> |
| 662 | To: Mary Smith <mary@example.net> |
| 663 | Subject: Saying Hello |
| 664 | Date: Fri, 21 Nov 1997 09:55:06 -0600 |
| 665 | Message-ID: <1234@local.node.example> |
| 666 | |
| 667 | This is a message just to say hello. |
| 668 | So, "Hello".` |