Skip to content

Commit 00326d4

Browse files
author
Mario Hros
committed
add test cases for quoted-printable (from ovadbar:quoted-printable DusanKasan#39)
1 parent 1130a3a commit 00326d4

File tree

1 file changed

+297
-0
lines changed

1 file changed

+297
-0
lines changed

parsemail_test.go

Lines changed: 297 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,78 @@ So, "Hello".`,
431431
},
432432
},
433433
},
434+
15: {
435+
contentType: "text/plain; charset=utf-8",
436+
mailData: rfc2045exampleA,
437+
subject: "Lead from Allstate LeadVantage",
438+
from: []mail.Address{
439+
{
440+
Address: "[email protected]",
441+
},
442+
},
443+
to: []mail.Address{
444+
{
445+
Address: "[email protected]",
446+
},
447+
},
448+
replyTo: []mail.Address{
449+
{
450+
Address: "[email protected]",
451+
},
452+
},
453+
messageID: "0100017fcf817777-481efc68-4a9a-4c11-ba2c-40ff0357e7b1-000000@email.amazonses.com",
454+
date: parseDate("Mon, 28 Mar 2022 07:50:42 +0000"),
455+
textBody: rfc2045exampleAtext,
456+
},
457+
16: {
458+
contentType: `text/html; charset="utf-8"`,
459+
mailData: rfc2045exampleB,
460+
subject: "New Business Property/Casualty Lead Received (#245200111)",
461+
from: []mail.Address{
462+
{
463+
Name: "AllWebLeads",
464+
Address: "[email protected]",
465+
},
466+
},
467+
to: []mail.Address{
468+
{
469+
Address: "[email protected]",
470+
},
471+
},
472+
replyTo: []mail.Address{
473+
{
474+
Address: "[email protected]",
475+
},
476+
},
477+
messageID: "[email protected]",
478+
date: parseDate("Tue, 29 Mar 2022 22:05:46 +0000"),
479+
htmlBody: rfc2045exampleBhtml,
480+
},
481+
17: {
482+
contentType: "multipart/related; boundary=\"000000000000ab2e2205a26de587\"",
483+
mailData: multipartRelatedExampleQuoted,
484+
subject: "Saying Hello",
485+
from: []mail.Address{
486+
{
487+
Name: "John Doe",
488+
Address: "[email protected]",
489+
},
490+
},
491+
sender: mail.Address{
492+
Name: "Michael Jones",
493+
Address: "[email protected]",
494+
},
495+
to: []mail.Address{
496+
{
497+
Name: "Mary Smith",
498+
Address: "[email protected]",
499+
},
500+
},
501+
messageID: "[email protected]",
502+
date: parseDate("Fri, 21 Nov 1997 09:55:06 -0600"),
503+
htmlBody: rfc2045exampleBhtml,
504+
textBody: "Time for the egg. Should we hardboil the egg or fry it. We can scramble it or poach it.",
505+
},
434506
}
435507

436508
for index, td := range testData {
@@ -1013,3 +1085,228 @@ Content-Disposition: attachment;
10131085
10141086
--f403045f1dcc043a44054c8e6bbf--
10151087
`
1088+
1089+
var rfc2045exampleA = `From 0100017fcf817777-481efc68-4a9a-4c11-ba2c-40ff0357e7b1-000000@amazonses.com Mon Mar 28 07:50:43 2022
1090+
Return-Path: <0100017fcf817777-481efc68-4a9a-4c11-ba2c-40ff0357e7b1-000000@amazonses.com>
1091+
X-Original-To: [email protected]
1092+
Delivered-To: [email protected]
1093+
Message-ID: <0100017fcf817777-481efc68-4a9a-4c11-ba2c-40ff0357e7b1-000000@email.amazonses.com>
1094+
Date: Mon, 28 Mar 2022 07:50:42 +0000
1095+
Subject: Lead from Allstate LeadVantage
1096+
1097+
1098+
1099+
Content-Type: text/plain; charset=utf-8
1100+
Content-Transfer-Encoding: quoted-printable
1101+
1102+
1103+
You just received a lead! Please check your lead management system, or u=
1104+
se the contact information
1105+
below. Please do not respond to this email ad=
1106+
dress, as it is not active. You may also view your leads
1107+
in Allstate Lead=
1108+
Vantage. Please call Allstate LeadVantage Support at 855-317-4233 or sign u=
1109+
p here:
1110+
https://allstateleadvantage.com/#/orders/list
1111+
1112+
Lead Informati=
1113+
on:
1114+
Unique ID: 138296007
1115+
Vertical: Auto Insurance
1116+
Alliance URL: https=
1117+
://agencygateway.allstate.com/ALLIANCE/launch?AgentNumber=3DA0c3858&ST=3DNV=
1118+
&FunctionType=3DAF&SourceOfLaunchPoint=3D01&ControlNumber=3D198220870336180=
1119+
1120+
Contact Information:
1121+
First Name: Brenda
1122+
Last Name: Qualls
1123+
Phone Nu=
1124+
mber: (702) 485-1038
1125+
Email Address: [email protected]
1126+
Street Add=
1127+
ress: 3236 Brayton Mist Dr
1128+
City: North Las Vegas
1129+
State: NV
1130+
Zip: 89081=
1131+
1132+
Are You A Homeowner: Yes
1133+
Best Time To Contact:=20
1134+
Vendor:
1135+
Vendor Nam=
1136+
e: Inside Response
1137+
Order Information:
1138+
Name: Custom Order 1
1139+
Policy Det=
1140+
ails:
1141+
Self Credit Rating: Good (620 - 719)
1142+
Currently Insured: Yes
1143+
Cur=
1144+
rent Insurance Company: State Farm County
1145+
Insured Since: 03/28/2020
1146+
Pol=
1147+
icy Start: 03/28/2020
1148+
Policy Expiration: 05/28/2022
1149+
Desired Coverage Ty=
1150+
pe: standard
1151+
Desired Collision Deductible: 1000
1152+
Desired Comprehensive D=
1153+
eductible: 1000
1154+
Driver 1:
1155+
Gender: female
1156+
Marital Status: married
1157+
Ed=
1158+
ucation Level: ged
1159+
Occupation: other
1160+
Date of Birth: 01/29/1981
1161+
Age Li=
1162+
censed: 19
1163+
Has Valid License: Yes
1164+
Has DUI: No
1165+
Requires SR-22: No
1166+
Re=
1167+
lation to applicant: self
1168+
Years Employed: 2
1169+
Years at Residence: 2
1170+
Has=
1171+
Tickets / Accidents: No
1172+
Vehicle 1:
1173+
Type: 2006 LEXUS SC 430 2WD CONVERT=
1174+
IBLE - 4.3L V8 FI DOHC 32V F
1175+
Vin: JTHFN48Y060000000
1176+
Leased: No
1177+
Pri=
1178+
mary Use: Pleasure Use Only
1179+
Commute Days: 5
1180+
Daily Mileage: 5
1181+
Annual M=
1182+
ileage: 15000
1183+
Has Alarm: Yes
1184+
Garage: nocover
1185+
`
1186+
1187+
var rfc2045exampleAtext string = `
1188+
You just received a lead! Please check your lead management system, or use the contact information
1189+
below. Please do not respond to this email address, as it is not active. You may also view your leads
1190+
in Allstate LeadVantage. Please call Allstate LeadVantage Support at 855-317-4233 or sign up here:
1191+
https://allstateleadvantage.com/#/orders/list
1192+
1193+
Lead Information:
1194+
Unique ID: 138296007
1195+
Vertical: Auto Insurance
1196+
Alliance URL: https://agencygateway.allstate.com/ALLIANCE/launch?AgentNumber=A0c3858&ST=NV&FunctionType=AF&SourceOfLaunchPoint=01&ControlNumber=198220870336180
1197+
Contact Information:
1198+
First Name: Brenda
1199+
Last Name: Qualls
1200+
Phone Number: (702) 485-1038
1201+
Email Address: [email protected]
1202+
Street Address: 3236 Brayton Mist Dr
1203+
City: North Las Vegas
1204+
State: NV
1205+
Zip: 89081
1206+
Are You A Homeowner: Yes
1207+
Best Time To Contact:
1208+
Vendor:
1209+
Vendor Name: Inside Response
1210+
Order Information:
1211+
Name: Custom Order 1
1212+
Policy Details:
1213+
Self Credit Rating: Good (620 - 719)
1214+
Currently Insured: Yes
1215+
Current Insurance Company: State Farm County
1216+
Insured Since: 03/28/2020
1217+
Policy Start: 03/28/2020
1218+
Policy Expiration: 05/28/2022
1219+
Desired Coverage Type: standard
1220+
Desired Collision Deductible: 1000
1221+
Desired Comprehensive Deductible: 1000
1222+
Driver 1:
1223+
Gender: female
1224+
Marital Status: married
1225+
Education Level: ged
1226+
Occupation: other
1227+
Date of Birth: 01/29/1981
1228+
Age Licensed: 19
1229+
Has Valid License: Yes
1230+
Has DUI: No
1231+
Requires SR-22: No
1232+
Relation to applicant: self
1233+
Years Employed: 2
1234+
Years at Residence: 2
1235+
Has Tickets / Accidents: No
1236+
Vehicle 1:
1237+
Type: 2006 LEXUS SC 430 2WD CONVERTIBLE - 4.3L V8 FI DOHC 32V F
1238+
Vin: JTHFN48Y060000000
1239+
Leased: No
1240+
Primary Use: Pleasure Use Only
1241+
Commute Days: 5
1242+
Daily Mileage: 5
1243+
Annual Mileage: 15000
1244+
Has Alarm: Yes
1245+
Garage: nocover`
1246+
1247+
var rfc2045exampleB string = `From v-biheobc_begnlldjf_icanamoe_icanamoe_a-1@bounce.allweb.mkt3103.com Tue Mar 29 22:05:46 2022
1248+
Return-Path: <v-biheobc_begnlldjf_icanamoe_icanamoe_a-1@bounce.allweb.mkt3103.com>
1249+
X-Original-To: [email protected]
1250+
Delivered-To: [email protected]
1251+
Received: by mail2792.allweb.mkt3188.com id h8e1bk2r7ao5 for <[email protected]>; Tue, 29 Mar 2022 22:05:46 +0000 (envelope-from <v-biheobc_begnlldjf_icanamoe_icanamoe_a-1@bounce.allweb.mkt3103.com>)
1252+
Date: Tue, 29 Mar 2022 22:05:46 +0000 (GMT)
1253+
From: AllWebLeads <[email protected]>
1254+
1255+
1256+
Message-ID: <[email protected]>
1257+
Subject: New Business Property/Casualty Lead Received (#245200111)
1258+
Content-Type: text/html; charset="utf-8"
1259+
Content-Transfer-Encoding: quoted-printable
1260+
1261+
<div dir=3D"ltr">
1262+
=09<div>Time for the egg.</div>
1263+
=09<div><br/></div>
1264+
=09<div><br/><br></div>
1265+
=09<div>Should we hardboil the egg or fry it. We can scramble it or poach i=
1266+
t.</div>
1267+
</div>`
1268+
1269+
var rfc2045exampleBhtml string = `<div dir="ltr">
1270+
<div>Time for the egg.</div>
1271+
<div><br/></div>
1272+
<div><br/><br></div>
1273+
<div>Should we hardboil the egg or fry it. We can scramble it or poach it.</div>
1274+
</div>`
1275+
var multipartRelatedExampleQuoted = `MIME-Version: 1.0
1276+
From: John Doe <[email protected]>
1277+
Sender: Michael Jones <[email protected]>
1278+
To: Mary Smith <[email protected]>
1279+
Subject: Saying Hello
1280+
Date: Fri, 21 Nov 1997 09:55:06 -0600
1281+
Message-ID: <[email protected]>
1282+
Subject: ooops
1283+
1284+
Content-Type: multipart/related; boundary="000000000000ab2e2205a26de587"
1285+
1286+
--000000000000ab2e2205a26de587
1287+
Content-Type: multipart/alternative; boundary="000000000000ab2e1f05a26de586"
1288+
1289+
--000000000000ab2e1f05a26de586
1290+
Content-Type: text/plain; charset="UTF-8"
1291+
Content-Transfer-Encoding: quoted-printable
1292+
1293+
Time for the egg. Should we hardboil the egg or fry it. We can scramble it =
1294+
or poach it.
1295+
1296+
--000000000000ab2e1f05a26de586
1297+
Content-Type: text/html; charset="UTF-8"
1298+
Content-Transfer-Encoding: quoted-printable
1299+
1300+
<div dir=3D"ltr">
1301+
=09<div>Time for the egg.</div>
1302+
=09<div><br/></div>
1303+
=09<div><br/><br></div>
1304+
=09<div>Should we hardboil the egg or fry it. We can scramble it or poach i=
1305+
t.</div>
1306+
</div>
1307+
1308+
--000000000000ab2e1f05a26de586--
1309+
1310+
1311+
--000000000000ab2e2205a26de587--
1312+
`

0 commit comments

Comments
 (0)