///|
pub fn corpus_messages() -> Array[String] {
[
simple_plain_eml(),
quoted_printable_eml(),
base64_eml(),
multipart_alternative_eml(),
multipart_mixed_with_attachment_eml(),
suspicious_attachment_eml(),
authenticated_route_eml(),
missing_boundary_eml(),
newsletter_eml(),
support_ticket_eml(),
build_failure_eml(),
calendar_notice_eml(),
password_reset_eml(),
invoice_notice_eml(),
delivery_failure_eml(),
tracked_newsletter_eml(),
thread_reply_eml(),
phishing_reset_eml(),
]
}
///|
pub fn parsed_corpus() -> Array[MailMessage] {
let out : Array[MailMessage] = []
for raw in corpus_messages() {
out.push(parse_message(raw).message)
}
out
}
///|
pub fn newsletter_eml() -> String {
"From: Moon Newsletter \r\n" +
"To: Fu \r\n" +
"Subject: August MoonBit Notes\r\n" +
"Date: Tue, 11 Aug 2026 08:30:00 +0800\r\n" +
"List-ID: Moon Newsletter \r\n" +
"List-Unsubscribe: , \r\n" +
"Content-Type: multipart/alternative; boundary=\"newsletter-alt\"\r\n" +
"\r\n" +
"--newsletter-alt\r\n" +
"Content-Type: text/plain; charset=utf-8\r\n" +
"\r\n" +
"Read the notes at https://example.com/moonbit-notes\r\n" +
"--newsletter-alt\r\n" +
"Content-Type: text/html; charset=utf-8\r\n" +
"\r\n" +
"MoonBit Notes
Read more at https://example.com/moonbit-notes
\r\n" +
"--newsletter-alt--\r\n"
}
///|
pub fn support_ticket_eml() -> String {
"From: Support Bot \r\n" +
"To: Fu \r\n" +
"Subject: Ticket #1024 updated\r\n" +
"Date: Tue, 11 Aug 2026 09:00:00 +0800\r\n" +
"Content-Type: text/plain; charset=utf-8\r\n" +
"\r\n" +
"Ticket #1024 changed status to waiting for customer.\r\n"
}
///|
pub fn build_failure_eml() -> String {
"From: CI \r\n" +
"To: Dev \r\n" +
"Subject: Build failed for main\r\n" +
"Date: Tue, 11 Aug 2026 09:10:00 +0800\r\n" +
"Authentication-Results: mx.example; spf=pass smtp.mailfrom=example.com\r\n" +
"Content-Type: text/plain; charset=utf-8\r\n" +
"\r\n" +
"The build failed. Logs: https://ci.example.com/build/123\r\n"
}
///|
pub fn calendar_notice_eml() -> String {
"From: Calendar \r\n" +
"To: Fu \r\n" +
"Subject: Meeting reminder\r\n" +
"Date: Tue, 11 Aug 2026 09:30:00 +0800\r\n" +
"Content-Type: multipart/mixed; boundary=\"cal-mix\"\r\n" +
"\r\n" +
"--cal-mix\r\n" +
"Content-Type: text/plain; charset=utf-8\r\n" +
"\r\n" +
"Reminder: project sync starts soon.\r\n" +
"--cal-mix\r\n" +
"Content-Type: text/calendar; name=\"invite.ics\"\r\n" +
"Content-Disposition: attachment; filename=\"invite.ics\"\r\n" +
"\r\n" +
"BEGIN:VCALENDAR\r\nEND:VCALENDAR\r\n" +
"--cal-mix--\r\n"
}
///|
pub fn password_reset_eml() -> String {
"From: Security \r\n" +
"To: Fu \r\n" +
"Subject: Password reset requested\r\n" +
"Date: Tue, 11 Aug 2026 09:45:00 +0800\r\n" +
"Content-Type: text/html; charset=utf-8\r\n" +
"\r\n" +
"Reset your password at https://example.com/reset?token=abc
\r\n"
}
///|
pub fn invoice_notice_eml() -> String {
"From: Billing \r\n" +
"To: Fu \r\n" +
"Subject: Invoice INV-2026-08\r\n" +
"Date: Tue, 11 Aug 2026 10:15:00 +0800\r\n" +
"Content-Type: multipart/mixed; boundary=\"invoice-mix\"\r\n" +
"\r\n" +
"--invoice-mix\r\n" +
"Content-Type: text/plain; charset=utf-8\r\n" +
"\r\n" +
"Your invoice is attached.\r\n" +
"--invoice-mix\r\n" +
"Content-Type: application/pdf; name=\"invoice.pdf\"\r\n" +
"Content-Disposition: attachment; filename=\"invoice.pdf\"\r\n" +
"Content-Transfer-Encoding: base64\r\n" +
"\r\n" +
"JVBERi0xLjQK\r\n" +
"--invoice-mix--\r\n"
}
///|
pub fn delivery_failure_eml() -> String {
"From: Mail Delivery Subsystem \r\n" +
"To: Fu \r\n" +
"Subject: Delivery Status Notification Failure\r\n" +
"Auto-Submitted: auto-replied\r\n" +
"Content-Type: multipart/report; boundary=\"dsn-report\"; report-type=delivery-status\r\n" +
"\r\n" +
"--dsn-report\r\n" +
"Content-Type: text/plain; charset=utf-8\r\n" +
"\r\n" +
"Delivery failed.\r\n" +
"--dsn-report\r\n" +
"Content-Type: message/delivery-status\r\n" +
"\r\n" +
"Final-Recipient: rfc822; missing@example.net\r\n" +
"Action: failed\r\n" +
"Status: 5.1.1\r\n" +
"Diagnostic-Code: smtp; 550 user unknown\r\n" +
"--dsn-report--\r\n"
}
///|
pub fn tracked_newsletter_eml() -> String {
"From: Offers \r\n" +
"To: Fu \r\n" +
"Subject: Special offer\r\n" +
"List-Unsubscribe: \r\n" +
"Content-Type: text/html; charset=utf-8\r\n" +
"\r\n" +
"Open deal
\r\n"
}
///|
pub fn thread_reply_eml() -> String {
"From: Dev \r\n" +
"To: Fu \r\n" +
"Subject: Re: Hello MoonMailKit\r\n" +
"Message-ID: \r\n" +
"In-Reply-To: \r\n" +
"References: \r\n" +
"Content-Type: text/plain; charset=utf-8\r\n" +
"\r\n" +
"Reply body.\r\n"
}
///|
pub fn phishing_reset_eml() -> String {
"Authentication-Results: mx.example; spf=fail smtp.mailfrom=bad.example; dkim=fail header.d=bad.example; dmarc=fail header.from=bad.example\r\n" +
"From: Security \r\n" +
"Reply-To: Help Desk \r\n" +
"To: Fu \r\n" +
"Subject: Verify your password reset\r\n" +
"Content-Type: text/html; charset=utf-8\r\n" +
"\r\n" +
"Please verify login at https://bad.example/login?verify=1
\r\n"
}