about summary refs log tree commit
diff options
context:
space:
mode:
authorEric Wong <e@yhbt.net>2020-04-21 21:16:13 +0000
committerEric Wong <e@yhbt.net>2020-04-22 18:26:01 +0000
commite6b7a7f5f70fb89a54ff158bc6c8b564149947e5 (patch)
treecd04e08c3f866875586774959fdb64e7e6bb78e8
parent62d1a4da996bd9a664be954f71f78fe052f9df16 (diff)
downloadpublic-inbox-e6b7a7f5f70fb89a54ff158bc6c8b564149947e5.tar.gz
Instead, favor PublicInbox::MIME->new for non-attachment emails.
We may support alternatives to Email::MIME down the line.

We'll still keep Email::MIME->create to deal with attachments,
for now, but there's also a fair amount of test duplication
we should eliminate, later.
-rw-r--r--t/altid.t19
-rw-r--r--t/altid_v2.t19
-rw-r--r--t/cgi.t8
-rw-r--r--t/content_id.t24
-rw-r--r--t/convert-compact.t22
-rw-r--r--t/feed.t6
-rw-r--r--t/filter_rubylang.t8
-rw-r--r--t/filter_subjecttag.t4
-rw-r--r--t/filter_vger.t6
-rw-r--r--t/html_index.t4
-rw-r--r--t/httpd.t4
-rw-r--r--t/import.t22
-rw-r--r--t/indexlevels-mirror.t21
-rw-r--r--t/mid.t5
-rw-r--r--t/msgtime.t51
-rw-r--r--t/nntp.t4
-rw-r--r--t/nntpd.t4
-rw-r--r--t/nulsubject.t18
-rw-r--r--t/plack.t4
-rw-r--r--t/psgi_attach.t2
-rw-r--r--t/psgi_mount.t4
-rw-r--r--t/psgi_multipart_not.t2
-rw-r--r--t/psgi_scan_all.t2
-rw-r--r--t/psgi_search.t2
-rw-r--r--t/psgi_text.t2
-rw-r--r--t/reply.t4
-rw-r--r--t/search-thr-index.t6
-rw-r--r--t/search.t205
-rw-r--r--t/time.t23
-rw-r--r--t/v1-add-remove-add.t22
-rw-r--r--t/v1reindex.t20
-rw-r--r--t/v2-add-remove-add.t22
-rw-r--r--t/v2mda.t23
-rw-r--r--t/v2reindex.t18
-rw-r--r--t/v2writable.t20
-rw-r--r--t/watch_maildir.t2
-rw-r--r--t/xcpdb-reshard.t17
37 files changed, 309 insertions, 340 deletions
diff --git a/t/altid.t b/t/altid.t
index 3134e627..c7a3601a 100644
--- a/t/altid.t
+++ b/t/altid.t
@@ -4,6 +4,7 @@ use strict;
 use warnings;
 use Test::More;
 use PublicInbox::TestCommon;
+use PublicInbox::MIME;
 require_mods(qw(DBD::SQLite Search::Xapian));
 use_ok 'PublicInbox::Msgmap';
 use_ok 'PublicInbox::SearchIdx';
@@ -26,16 +27,14 @@ my $ibx;
         my $git = PublicInbox::Git->new($git_dir);
         my $im = PublicInbox::Import->new($git, 'testbox', 'test@example');
         $im->init_bare;
-        $im->add(Email::MIME->create(
-                header => [
-                        From => 'a@example.com',
-                        To => 'b@example.com',
-                        'Content-Type' => 'text/plain',
-                        Subject => 'boo!',
-                        'Message-ID' => '<a@example.com>',
-                ],
-                body => "hello world gmane:666\n",
-        ));
+        $im->add(PublicInbox::MIME->new(<<'EOF'));
+From: a@example.com
+To: b@example.com
+Subject: boo!
+Message-ID: <a@example.com>
+
+hello world gmane:666
+EOF
         $im->done;
 }
 {
diff --git a/t/altid_v2.t b/t/altid_v2.t
index f31061c2..3ac294f0 100644
--- a/t/altid_v2.t
+++ b/t/altid_v2.t
@@ -3,6 +3,7 @@
 use strict;
 use warnings;
 use Test::More;
+use PublicInbox::MIME;
 use PublicInbox::TestCommon;
 require_git(2.6);
 require_mods(qw(DBD::SQLite Search::Xapian));
@@ -30,16 +31,14 @@ my $ibx = {
 };
 $ibx = PublicInbox::Inbox->new($ibx);
 my $v2w = PublicInbox::V2Writable->new($ibx, 1);
-$v2w->add(Email::MIME->create(
-                header => [
-                        From => 'a@example.com',
-                        To => 'b@example.com',
-                        'Content-Type' => 'text/plain',
-                        Subject => 'boo!',
-                        'Message-ID' => '<a@example.com>',
-                ],
-                body => "hello world gmane:666\n",
-        ));
+$v2w->add(PublicInbox::MIME->new(<<'EOF'));
+From: a@example.com
+To: b@example.com
+Subject: boo!
+Message-ID: <a@example.com>
+
+hello world gmane:666
+EOF
 $v2w->done;
 
 my $msgs = $ibx->search->reopen->query("gmane:1234");
diff --git a/t/cgi.t b/t/cgi.t
index bceb83e5..42a343d3 100644
--- a/t/cgi.t
+++ b/t/cgi.t
@@ -5,7 +5,7 @@
 use strict;
 use warnings;
 use Test::More;
-use Email::MIME;
+use PublicInbox::MIME;
 use PublicInbox::TestCommon;
 use PublicInbox::Import;
 require_mods(qw(Plack::Handler::CGI Plack::Util));
@@ -45,7 +45,7 @@ my $im = PublicInbox::InboxWritable->new($ibx)->importer;
         local $ENV{HOME} = $home;
 
         # inject some messages:
-        my $mime = Email::MIME->new(<<EOF);
+        my $mime = PublicInbox::MIME->new(<<EOF);
 From: Me <me\@example.com>
 To: You <you\@example.com>
 Cc: $addr
@@ -62,7 +62,7 @@ EOF
         ok($im->add($mime), 'added big message');
 
         # deliver a reply, too
-        $mime = Email::MIME->new(<<EOF);
+        $mime = PublicInbox::MIME->new(<<EOF);
 From: You <you\@example.com>
 To: Me <me\@example.com>
 Cc: $addr
@@ -79,7 +79,7 @@ EOF
         ok($im->add($mime), 'added reply');
 
         my $slashy_mid = 'slashy/asdf@example.com';
-        my $slashy = Email::MIME->new(<<EOF);
+        my $slashy = PublicInbox::MIME->new(<<EOF);
 From: You <you\@example.com>
 To: Me <me\@example.com>
 Cc: $addr
diff --git a/t/content_id.t b/t/content_id.t
index 3fe44b95..0325164d 100644
--- a/t/content_id.t
+++ b/t/content_id.t
@@ -4,22 +4,20 @@ use strict;
 use warnings;
 use Test::More;
 use PublicInbox::ContentId qw(content_id);
-use Email::MIME;
+use PublicInbox::MIME;
 
-my $mime = Email::MIME->create(
-        header => [
-                From => 'a@example.com',
-                To => 'b@example.com',
-                'Content-Type' => 'text/plain',
-                Subject => 'this is a subject',
-                'Message-ID' => '<a@example.com>',
-                Date => 'Fri, 02 Oct 1993 00:00:00 +0000',
-        ],
-        body => "hello world\n",
-);
+my $mime = PublicInbox::MIME->new(<<'EOF');
+From: a@example.com
+To: b@example.com
+Subject: this is a subject
+Message-ID: <a@example.com>
+Date: Fri, 02 Oct 1993 00:00:00 +0000
+
+hello world
+EOF
 
 my $orig = content_id($mime);
-my $reload = content_id(Email::MIME->new($mime->as_string));
+my $reload = content_id(PublicInbox::MIME->new($mime->as_string));
 is($orig, $reload, 'content_id matches after serialization');
 
 foreach my $h (qw(From To Cc)) {
diff --git a/t/convert-compact.t b/t/convert-compact.t
index 376e0f6a..ae299021 100644
--- a/t/convert-compact.t
+++ b/t/convert-compact.t
@@ -7,7 +7,7 @@ use PublicInbox::MIME;
 use PublicInbox::Spawn qw(which);
 use PublicInbox::TestCommon;
 require_git(2.6);
-require_mods(qw(DBD::SQLite Search::Xapian Email::MIME));
+require_mods(qw(DBD::SQLite Search::Xapian));
 which('xapian-compact') or
         plan skip_all => 'xapian-compact missing for '.__FILE__;
 
@@ -26,16 +26,16 @@ ok(PublicInbox::Import::run_die([qw(git) , "--git-dir=$ibx->{inboxdir}",
         qw(config core.sharedRepository 0644)]), 'set sharedRepository');
 $ibx = PublicInbox::Inbox->new($ibx);
 my $im = PublicInbox::Import->new($ibx->git, undef, undef, $ibx);
-my $mime = Email::MIME->create(
-        header => [
-                From => 'a@example.com',
-                To => 'test@example.com',
-                Subject => 'this is a subject',
-                'Message-ID' => '<a-mid@b>',
-                Date => 'Fri, 02 Oct 1993 00:00:00 +0000',
-        ],
-        body => "hello world\n",
-);
+my $mime = PublicInbox::MIME->new(<<'EOF');
+From: a@example.com
+To: b@example.com
+Subject: this is a subject
+Message-ID: <a-mid@b>
+Date: Fri, 02 Oct 1993 00:00:00 +0000
+
+hello world
+EOF
+
 ok($im->add($mime), 'added one message');
 ok($im->remove($mime), 'remove message');
 ok($im->add($mime), 'added message again');
diff --git a/t/feed.t b/t/feed.t
index 7d01e3e6..373a1de8 100644
--- a/t/feed.t
+++ b/t/feed.t
@@ -3,7 +3,7 @@
 use strict;
 use warnings;
 use Test::More;
-use Email::MIME;
+use PublicInbox::MIME;
 use PublicInbox::Feed;
 use PublicInbox::Import;
 use PublicInbox::Inbox;
@@ -36,7 +36,7 @@ my $im = PublicInbox::Import->new($git, $ibx->{name}, 'test@example');
 {
         $im->init_bare;
         foreach my $i (1..6) {
-                my $mime = Email::MIME->new(<<EOF);
+                my $mime = PublicInbox::MIME->new(<<EOF);
 From: ME <me\@example.com>
 To: U <u\@example.com>
 Message-Id: <$i\@example.com>
@@ -95,7 +95,7 @@ EOF
         # add a new spam message
         my $spam;
         {
-                $spam = Email::MIME->new(<<EOF);
+                $spam = PublicInbox::MIME->new(<<EOF);
 From: SPAMMER <spammer\@example.com>
 To: U <u\@example.com>
 Message-Id: <this-is-spam\@example.com>
diff --git a/t/filter_rubylang.t b/t/filter_rubylang.t
index 8215b6f1..05e1b324 100644
--- a/t/filter_rubylang.t
+++ b/t/filter_rubylang.t
@@ -3,7 +3,7 @@
 use strict;
 use warnings;
 use Test::More;
-use Email::MIME;
+use PublicInbox::MIME;
 use PublicInbox::TestCommon;
 use_ok 'PublicInbox::Filter::RubyLang';
 
@@ -17,7 +17,7 @@ keep this
 Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
 <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>
 EOF
-my $mime = Email::MIME->new($msg);
+my $mime = PublicInbox::MIME->new($msg);
 my $ret = $f->delivery($mime);
 is($ret, $mime, "delivery successful");
 is($mime->body, "keep this\n", 'normal message filtered OK');
@@ -41,7 +41,7 @@ X-Mail-Count: 12
 Message-ID: <a@b>
 
 EOF
-        $mime = Email::MIME->new($msg);
+        $mime = PublicInbox::MIME->new($msg);
         $ret = $f->delivery($mime);
         is($ret, $mime, "delivery successful");
         my $mm = PublicInbox::Msgmap->new($git_dir);
@@ -53,7 +53,7 @@ Message-ID: <b@b>
 
 EOF
 
-        $mime = Email::MIME->new($msg);
+        $mime = PublicInbox::MIME->new($msg);
         $ret = $f->delivery($mime);
         is($ret, 100, "delivery rejected without X-Mail-Count");
 }
diff --git a/t/filter_subjecttag.t b/t/filter_subjecttag.t
index 922499d5..9b397b8c 100644
--- a/t/filter_subjecttag.t
+++ b/t/filter_subjecttag.t
@@ -3,7 +3,7 @@
 use strict;
 use warnings;
 use Test::More;
-use Email::MIME;
+use PublicInbox::MIME;
 use_ok 'PublicInbox::Filter::SubjectTag';
 
 my $f = eval { PublicInbox::Filter::SubjectTag->new };
@@ -11,7 +11,7 @@ like($@, qr/tag not defined/, 'error without args');
 $f = PublicInbox::Filter::SubjectTag->new('-tag', '[foo]');
 is(ref $f, 'PublicInbox::Filter::SubjectTag', 'new object created');
 
-my $mime = Email::MIME->new(<<EOF);
+my $mime = PublicInbox::MIME->new(<<EOF);
 To: you <you\@example.com>
 Subject: =?UTF-8?B?UmU6IFtmb29dIEVsw4PCqWFub3I=?=
 
diff --git a/t/filter_vger.t b/t/filter_vger.t
index 0f0562ed..9d71f16d 100644
--- a/t/filter_vger.t
+++ b/t/filter_vger.t
@@ -3,7 +3,7 @@
 use strict;
 use warnings;
 use Test::More;
-use Email::MIME;
+use PublicInbox::MIME;
 use_ok 'PublicInbox::Filter::Vger';
 
 my $f = PublicInbox::Filter::Vger->new;
@@ -21,7 +21,7 @@ More majordomo info at  http://vger.kernel.org/majordomo-info.html
 Please read the FAQ at  http://www.tux.org/lkml/
 EOF
 
-        my $mime = Email::MIME->new($lkml);
+        my $mime = PublicInbox::MIME->new($lkml);
         $mime = $f->delivery($mime);
         is("keep this\n", $mime->body, 'normal message filtered OK');
 }
@@ -37,7 +37,7 @@ the body of a message to majordomo@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html
 EOF
 
-        my $mime = Email::MIME->new($no_nl);
+        my $mime = PublicInbox::MIME->new($no_nl);
         $mime = $f->delivery($mime);
         is('OSX users :P', $mime->body, 'missing trailing LF in original OK');
 }
diff --git a/t/html_index.t b/t/html_index.t
index fda3962a..51897532 100644
--- a/t/html_index.t
+++ b/t/html_index.t
@@ -3,7 +3,7 @@
 use strict;
 use warnings;
 use Test::More;
-use Email::MIME;
+use PublicInbox::MIME;
 use PublicInbox::Feed;
 use PublicInbox::Git;
 use PublicInbox::Import;
@@ -32,7 +32,7 @@ my $im = PublicInbox::Import->new($git, 'tester', 'test@example');
                         $mid_line .= "In-Reply-To: $prev";
                 }
                 $prev = $mid;
-                my $mime = Email::MIME->new(<<EOF);
+                my $mime = PublicInbox::MIME->new(<<EOF);
 From: ME <me\@example.com>
 To: U <u\@example.com>
 $mid_line
diff --git a/t/httpd.t b/t/httpd.t
index 61aec3b4..f4fbd533 100644
--- a/t/httpd.t
+++ b/t/httpd.t
@@ -4,6 +4,7 @@ use strict;
 use warnings;
 use Test::More;
 use PublicInbox::TestCommon;
+use PublicInbox::MIME;
 use Socket qw(IPPROTO_TCP SOL_SOCKET);
 require_mods(qw(Plack::Util Plack::Builder HTTP::Date HTTP::Status));
 
@@ -20,7 +21,6 @@ my $sock = tcp_server();
 my $td;
 use_ok 'PublicInbox::Git';
 use_ok 'PublicInbox::Import';
-use_ok 'Email::MIME';
 {
         local $ENV{HOME} = $home;
         my $cmd = [ '-init', $group, $maindir, 'http://example.com/', $addr ];
@@ -28,7 +28,7 @@ use_ok 'Email::MIME';
 
         # ensure successful message delivery
         {
-                my $mime = Email::MIME->new(<<EOF);
+                my $mime = PublicInbox::MIME->new(<<EOF);
 From: Me <me\@example.com>
 To: You <you\@example.com>
 Cc: $addr
diff --git a/t/import.t b/t/import.t
index 53345b12..d2264102 100644
--- a/t/import.t
+++ b/t/import.t
@@ -10,23 +10,21 @@ use PublicInbox::Spawn qw(spawn);
 use Fcntl qw(:DEFAULT SEEK_SET);
 use File::Temp qw/tempfile/;
 use PublicInbox::TestCommon;
-require_mods(qw(Email::MIME));
 my ($dir, $for_destroy) = tmpdir();
 
 my $git = PublicInbox::Git->new($dir);
 my $im = PublicInbox::Import->new($git, 'testbox', 'test@example');
 $im->init_bare;
-my $mime = Email::MIME->create(
-        header => [
-                From => 'a@example.com',
-                To => 'b@example.com',
-                'Content-Type' => 'text/plain',
-                Subject => 'this is a subject',
-                'Message-ID' => '<a@example.com>',
-                Date => 'Fri, 02 Oct 1993 00:00:00 +0000',
-        ],
-        body => "hello world\n",
-);
+my $mime = PublicInbox::MIME->new(<<'EOF');
+From: a@example.com
+To: b@example.com
+Subject: this is a subject
+Message-ID: <a@example.com>
+Date: Fri, 02 Oct 1993 00:00:00 +0000
+
+hello world
+EOF
+
 my $v2 = require_git(2.6, 1);
 my $smsg = {} if $v2;
 like($im->add($mime, undef, $smsg), qr/\A:[0-9]+\z/, 'added one message');
diff --git a/t/indexlevels-mirror.t b/t/indexlevels-mirror.t
index 90506e28..dcd5dc39 100644
--- a/t/indexlevels-mirror.t
+++ b/t/indexlevels-mirror.t
@@ -10,17 +10,16 @@ require PublicInbox::Admin;
 use PublicInbox::TestCommon;
 my $PI_TEST_VERSION = $ENV{PI_TEST_VERSION} || 2;
 require_git('2.6') if $PI_TEST_VERSION == 2;
-require_mods(qw(DBD::SQLite Email::MIME));
-
-my $mime = Email::MIME->create(
-        header => [
-                From => 'a@example.com',
-                To => 'test@example.com',
-                Subject => 'this is a subject',
-                Date => 'Fri, 02 Oct 1993 00:00:00 +0000',
-        ],
-        body => "hello world\n",
-);
+require_mods(qw(DBD::SQLite));
+
+my $mime = PublicInbox::MIME->new(<<'EOF');
+From: a@example.com
+To: test@example.com
+Subject: this is a subject
+Date: Fri, 02 Oct 1993 00:00:00 +0000
+
+hello world
+EOF
 
 sub import_index_incremental {
         my ($v, $level, $mime) = @_;
diff --git a/t/mid.t b/t/mid.t
index 9815d384..0ad81d7d 100644
--- a/t/mid.t
+++ b/t/mid.t
@@ -2,6 +2,7 @@
 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
 use strict;
 use Test::More;
+use PublicInbox::MIME;
 use PublicInbox::MID qw(mid_escape mids references mids_for_index id_compress);
 
 is(mid_escape('foo!@(bar)'), 'foo!@(bar)');
@@ -15,10 +16,8 @@ like(id_compress('foo%bar@wtf'), qr/\A[a-f0-9]{40}\z/,
 is(id_compress('foobar-wtf'), 'foobar-wtf', 'regular ID not compressed');
 
 {
-        use Email::MIME;
-        my $mime = Email::MIME->create;
+        my $mime = PublicInbox::MIME->new("Message-ID: <mid-1\@a>\n\n");
         $mime->header_set('X-Alt-Message-ID', '<alt-id-for-nntp>');
-        $mime->header_set('Message-Id', '<mid-1@a>');
         is_deeply(['mid-1@a'], mids($mime->header_obj), 'mids in common case');
         $mime->header_set('Message-Id', '<mid-1@a>', '<mid-2@b>');
         is_deeply(['mid-1@a', 'mid-2@b'], mids($mime->header_obj), '2 mids');
diff --git a/t/msgtime.t b/t/msgtime.t
index 058f3886..d9f8e641 100644
--- a/t/msgtime.t
+++ b/t/msgtime.t
@@ -6,28 +6,23 @@ use Test::More;
 use PublicInbox::MIME;
 use PublicInbox::MsgTime;
 use PublicInbox::TestCommon;
-require_mods(qw(Email::MIME));
 
 our $received_date = 'Mon, 22 Jan 2007 13:16:24 -0500';
 sub datestamp ($) {
         my ($date) = @_;
         local $SIG{__WARN__} = sub {};  # Suppress warnings
-        my $mime = Email::MIME->create(
-                header => [
-                        From => 'a@example.com',
-                        To => 'b@example.com',
-                        'Content-Type' => 'text/plain',
-                        Subject => 'this is a subject',
-                        'Message-ID' => '<a@example.com>',
-                        Date => $date,
-                        'Received' => <<EOF,
-(majordomo\@vger.kernel.org) by vger.kernel.org via listexpand
-\tid S932173AbXAVSQY (ORCPT <rfc822;w\@1wt.eu>);
-\t$received_date
+        my $mime = PublicInbox::MIME->new(<<"EOF");
+From: a\@example.com
+To: b\@example.com
+Subject: this is a subject
+Message-ID: <a\@example.com>
+Date: $date
+Received: (majordomo\@vger.kernel.org) by vger.kernel.org via listexpand
+        id S932173AbXAVSQY (ORCPT <rfc822;w\@1wt.eu>);
+        $received_date
+
+hello world
 EOF
-                ],
-                body => "hello world\n",
-            );
         my @ts = PublicInbox::MsgTime::msg_datestamp($mime->header_obj);
         return \@ts;
 }
@@ -35,18 +30,18 @@ EOF
 sub timestamp ($) {
         my ($received) = @_;
         local $SIG{__WARN__} = sub {};  # Suppress warnings
-        my $mime = Email::MIME->create(
-                header => [
-                        From => 'a@example.com',
-                        To => 'b@example.com',
-                        'Content-Type' => 'text/plain',
-                        Subject => 'this is a subject',
-                        'Message-ID' => '<a@example.com>',
-                        Date => 'Fri, 02 Oct 1993 00:00:00 +0000',
-                        'Received' => '(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S932173AbXAVSQY (ORCPT <rfc822;w@1wt.eu>);\n\t' . $received,
-                ],
-                body => "hello world\n",
-            );
+        my $mime = PublicInbox::MIME->new(<<"EOF");
+From: a\@example.com
+To: b\@example.com
+Subject: this is a subject
+Message-ID: <a\@example.com>
+Date: Fri, 02 Oct 1993 00:00:00 +0000
+Received: (majordomo\@vger.kernel.org) by vger.kernel.org via listexpand
+        id S932173AbXAVSQY (ORCPT <rfc822;w\@1wt.eu>);
+        $received
+
+hello world
+EOF
         my @ts = PublicInbox::MsgTime::msg_timestamp($mime->header_obj);
         return \@ts;
 }
diff --git a/t/nntp.t b/t/nntp.t
index ff72ec6a..35fb55b4 100644
--- a/t/nntp.t
+++ b/t/nntp.t
@@ -4,6 +4,7 @@ use strict;
 use warnings;
 use Test::More;
 use PublicInbox::TestCommon;
+use PublicInbox::MIME;
 require_mods(qw(DBD::SQLite Data::Dumper));
 use_ok 'PublicInbox::NNTP';
 use_ok 'PublicInbox::Inbox';
@@ -96,7 +97,6 @@ use_ok 'PublicInbox::Inbox';
 }
 
 { # test setting NNTP headers in HEAD and ARTICLE requests
-        require Email::MIME;
         my $u = 'https://example.com/a/';
         my $ng = PublicInbox::Inbox->new({ name => 'test',
                                         inboxdir => 'test.git',
@@ -107,7 +107,7 @@ use_ok 'PublicInbox::Inbox';
                                         url => [ '//example.com/a' ]});
         is($ng->base_url, $u, 'URL expanded');
         my $mid = 'a@b';
-        my $mime = Email::MIME->new("Message-ID: <$mid>\r\n\r\n");
+        my $mime = PublicInbox::MIME->new("Message-ID: <$mid>\r\n\r\n");
         my $hdr = $mime->header_obj;
         my $mock_self = { nntpd => { grouplist => [],
                                      servername => 'example.com' } };
diff --git a/t/nntpd.t b/t/nntpd.t
index 5a3a62fb..4993b29f 100644
--- a/t/nntpd.t
+++ b/t/nntpd.t
@@ -7,7 +7,7 @@ use PublicInbox::TestCommon;
 use PublicInbox::Spawn qw(which);
 require_mods(qw(DBD::SQLite));
 require PublicInbox::InboxWritable;
-use Email::Simple;
+use PublicInbox::MIME;
 use IO::Socket;
 use Socket qw(IPPROTO_TCP TCP_NODELAY);
 use Net::NNTP;
@@ -57,7 +57,7 @@ $ibx = PublicInbox::Inbox->new($ibx);
 
         # ensure successful message delivery
         {
-                my $mime = Email::MIME->new(<<EOF);
+                my $mime = PublicInbox::MIME->new(<<EOF);
 To: =?utf-8?Q?El=C3=A9anor?= <you\@example.com>
 From: =?utf-8?Q?El=C3=A9anor?= <me\@example.com>
 Cc: $addr
diff --git a/t/nulsubject.t b/t/nulsubject.t
index 1ded88d3..03b1ee80 100644
--- a/t/nulsubject.t
+++ b/t/nulsubject.t
@@ -14,16 +14,14 @@ my $git_dir = "$tmpdir/a.git";
         my $git = PublicInbox::Git->new($git_dir);
         my $im = PublicInbox::Import->new($git, 'testbox', 'test@example');
         $im->init_bare;
-        $im->add(Email::MIME->create(
-                header => [
-                        From => 'a@example.com',
-                        To => 'b@example.com',
-                        'Content-Type' => 'text/plain',
-                        Subject => ' A subject line with a null =?iso-8859-1?q?=00?= see!',
-                        'Message-ID' => '<null-test.a@example.com>',
-                ],
-                body => "hello world\n",
-        ));
+        $im->add(PublicInbox::MIME->new(<<'EOF'));
+From: a@example.com
+To: b@example.com
+Subject: A subject line with a null =?iso-8859-1?q?=00?= see!
+Message-ID: <null-test.a@example.com>
+
+hello world
+EOF
         $im->done;
         is(xsys(qw(git --git-dir), $git_dir, 'fsck', '--strict'), 0,
                 'git fsck ok');
diff --git a/t/plack.t b/t/plack.t
index ea318792..b16bc8de 100644
--- a/t/plack.t
+++ b/t/plack.t
@@ -32,7 +32,7 @@ my $git = PublicInbox::Git->new($inboxdir);
 my $im = PublicInbox::Import->new($git, 'test', $addr);
 # ensure successful message delivery
 {
-        my $mime = Email::MIME->new(<<EOF);
+        my $mime = PublicInbox::MIME->new(<<EOF);
 From: Me <me\@example.com>
 To: You <you\@example.com>
 Cc: $addr
@@ -124,7 +124,7 @@ Date: Fri, 02 Oct 1993 00:00:00 +0000
 :(
 EOF
         $crlf =~ s/\n/\r\n/sg;
-        $im->add(Email::MIME->new($crlf));
+        $im->add(PublicInbox::MIME->new($crlf));
 
         $im->done;
 }
diff --git a/t/psgi_attach.t b/t/psgi_attach.t
index a47f3754..2376bba7 100644
--- a/t/psgi_attach.t
+++ b/t/psgi_attach.t
@@ -68,7 +68,7 @@ $im->init_bare;
         );
         $mime = $mime->as_string;
         $mime =~ s/\r\n/\n/g; # normalize to LF only
-        $mime = Email::MIME->new($mime);
+        $mime = PublicInbox::MIME->new($mime);
         $im->add($mime);
         $im->done;
 
diff --git a/t/psgi_mount.t b/t/psgi_mount.t
index 3afb1fb5..bd492dcb 100644
--- a/t/psgi_mount.t
+++ b/t/psgi_mount.t
@@ -3,7 +3,7 @@
 use strict;
 use warnings;
 use Test::More;
-use Email::MIME;
+use PublicInbox::MIME;
 use PublicInbox::TestCommon;
 my ($tmpdir, $for_destroy) = tmpdir();
 my $maindir = "$tmpdir/main.git";
@@ -25,7 +25,7 @@ my $git = PublicInbox::Git->new($maindir);
 my $im = PublicInbox::Import->new($git, 'test', $addr);
 $im->init_bare;
 {
-        my $mime = Email::MIME->new(<<EOF);
+        my $mime = PublicInbox::MIME->new(<<EOF);
 From: Me <me\@example.com>
 To: You <you\@example.com>
 Cc: $addr
diff --git a/t/psgi_multipart_not.t b/t/psgi_multipart_not.t
index 7ef97d43..ef86c015 100644
--- a/t/psgi_multipart_not.t
+++ b/t/psgi_multipart_not.t
@@ -3,7 +3,7 @@
 use strict;
 use warnings;
 use Test::More;
-use Email::MIME;
+use PublicInbox::MIME;
 use PublicInbox::Config;
 use PublicInbox::TestCommon;
 my @mods = qw(DBD::SQLite Search::Xapian HTTP::Request::Common
diff --git a/t/psgi_scan_all.t b/t/psgi_scan_all.t
index 4d593941..93603a33 100644
--- a/t/psgi_scan_all.t
+++ b/t/psgi_scan_all.t
@@ -3,7 +3,7 @@
 use strict;
 use warnings;
 use Test::More;
-use Email::MIME;
+use PublicInbox::MIME;
 use PublicInbox::Config;
 use PublicInbox::TestCommon;
 my @mods = qw(HTTP::Request::Common Plack::Test URI::Escape DBD::SQLite);
diff --git a/t/psgi_search.t b/t/psgi_search.t
index 4fe315a1..3c515d19 100644
--- a/t/psgi_search.t
+++ b/t/psgi_search.t
@@ -3,7 +3,7 @@
 use strict;
 use warnings;
 use Test::More;
-use Email::MIME;
+use PublicInbox::MIME;
 use PublicInbox::Config;
 use PublicInbox::Inbox;
 use PublicInbox::InboxWritable;
diff --git a/t/psgi_text.t b/t/psgi_text.t
index 77fc9ee2..b7b5b2d4 100644
--- a/t/psgi_text.t
+++ b/t/psgi_text.t
@@ -3,7 +3,7 @@
 use strict;
 use warnings;
 use Test::More;
-use Email::MIME;
+use PublicInbox::MIME;
 use PublicInbox::TestCommon;
 my ($tmpdir, $for_destroy) = tmpdir();
 my $maindir = "$tmpdir/main.git";
diff --git a/t/reply.t b/t/reply.t
index fbb3e1b8..a6c38cfa 100644
--- a/t/reply.t
+++ b/t/reply.t
@@ -3,7 +3,7 @@
 use strict;
 use warnings;
 use Test::More;
-use Email::MIME;
+use PublicInbox::MIME;
 use_ok 'PublicInbox::Reply';
 
 my @q = (
@@ -19,7 +19,7 @@ while (@q) {
         is($res, $expect, "quote $input => $res");
 }
 
-my $mime = Email::MIME->new(<<'EOF');
+my $mime = PublicInbox::MIME->new(<<'EOF');
 From: from <from@example.com>
 To: to <to@example.com>
 Cc: cc@example.com
diff --git a/t/search-thr-index.t b/t/search-thr-index.t
index 6c564b19..1bea59fd 100644
--- a/t/search-thr-index.t
+++ b/t/search-thr-index.t
@@ -6,7 +6,7 @@ use bytes (); # only for bytes::length
 use Test::More;
 use PublicInbox::TestCommon;
 use PublicInbox::MID qw(mids);
-use Email::MIME;
+use PublicInbox::MIME;
 require_mods(qw(DBD::SQLite Search::Xapian));
 require PublicInbox::SearchIdx;
 require PublicInbox::Smsg;
@@ -42,7 +42,7 @@ my @mids;
 
 foreach (reverse split(/\n\n/, $data)) {
         $_ .= "\n";
-        my $mime = Email::MIME->new(\$_);
+        my $mime = PublicInbox::MIME->new(\$_);
         $mime->header_set('From' => 'bw@g');
         $mime->header_set('To' => 'git@vger.kernel.org');
         my $bytes = bytes::length($mime->as_string);
@@ -78,7 +78,7 @@ $rw->commit_txn_lazy;
 
 $xdb = $rw->begin_txn_lazy;
 {
-        my $mime = Email::MIME->new(<<'');
+        my $mime = PublicInbox::MIME->new(<<'');
 Subject: [RFC 00/14]
 Message-Id: <1-bw@g>
 From: bw@g
diff --git a/t/search.t b/t/search.t
index 8508f273..0fd5fdee 100644
--- a/t/search.t
+++ b/t/search.t
@@ -4,11 +4,11 @@ use strict;
 use warnings;
 use Test::More;
 use PublicInbox::TestCommon;
-require_mods(qw(DBD::SQLite Search::Xapian));
+require_mods(qw(DBD::SQLite Search::Xapian Email::MIME));
 require PublicInbox::SearchIdx;
 require PublicInbox::Inbox;
 require PublicInbox::InboxWritable;
-use Email::MIME;
+use PublicInbox::MIME;
 my ($tmpdir, $for_destroy) = tmpdir();
 my $git_dir = "$tmpdir/a.git";
 my $ibx = PublicInbox::Inbox->new({ inboxdir => $git_dir });
@@ -60,27 +60,26 @@ sub oct_is ($$$) {
 }
 
 $ibx->with_umask(sub {
-        my $root = Email::MIME->create(
-                header_str => [
-                        Date => 'Fri, 02 Oct 1993 00:00:00 +0000',
-                        Subject => 'Hello world',
-                        'Message-ID' => '<root@s>',
-                        From => 'John Smith <js@example.com>',
-                        To => 'list@example.com',
-                ],
-                body => "\\m/\n");
-        my $last = Email::MIME->create(
-                header_str => [
-                        Date => 'Sat, 02 Oct 2010 00:00:00 +0000',
-                        Subject => 'Re: Hello world',
-                        'In-Reply-To' => '<root@s>',
-                        'Message-ID' => '<last@s>',
-                        From => 'John Smith <js@example.com>',
-                        To => 'list@example.com',
-                        Cc => 'foo@example.com',
-                ],
-                body => "goodbye forever :<\n");
-
+        my $root = PublicInbox::MIME->new(<<'EOF');
+Date: Fri, 02 Oct 1993 00:00:00 +0000
+Subject: Hello world
+Message-ID: <root@s>
+From: John Smith <js@example.com>
+To: list@example.com
+
+\m/
+EOF
+        my $last = PublicInbox::MIME->new(<<'EOF');
+Date: Sat, 02 Oct 2010 00:00:00 +0000
+Subject: Re: Hello world
+In-Reply-To: <root@s>
+Message-ID: <last@s>
+From: John Smith <js@example.com>
+To: list@example.com
+Cc: foo@example.com
+
+goodbye forever :<
+EOF
         my $rv;
         $rw_commit->();
         $root_id = $rw->add_message($root);
@@ -127,31 +126,29 @@ sub filter_mids {
 $ibx->with_umask(sub {
         $rw_commit->();
         my $rmid = '<ghost-message@s>';
-        my $reply_to_ghost = Email::MIME->create(
-                header_str => [
-                        Date => 'Sat, 02 Oct 2010 00:00:00 +0000',
-                        Subject => 'Re: ghosts',
-                        'Message-ID' => '<ghost-reply@s>',
-                        'In-Reply-To' => $rmid,
-                        From => 'Time Traveler <tt@example.com>',
-                        To => 'list@example.com',
-                ],
-                body => "-_-\n");
-
+        my $reply_to_ghost = PublicInbox::MIME->new(<<"EOF");
+Date: Sat, 02 Oct 2010 00:00:00 +0000
+Subject: Re: ghosts
+Message-ID: <ghost-reply\@s>
+In-Reply-To: $rmid
+From: Time Traveler <tt\@example.com>
+To: list\@example.com
+
+-_-
+EOF
         my $rv;
         my $reply_id = $rw->add_message($reply_to_ghost);
         is($reply_id, int($reply_id), "reply_id is an integer: $reply_id");
 
-        my $was_ghost = Email::MIME->create(
-                header_str => [
-                        Date => 'Sat, 02 Oct 2010 00:00:01 +0000',
-                        Subject => 'ghosts',
-                        'Message-ID' => $rmid,
-                        From => 'Laggy Sender <lag@example.com>',
-                        To => 'list@example.com',
-                ],
-                body => "are real\n");
+        my $was_ghost = PublicInbox::MIME->new(<<"EOF");
+Date: Sat, 02 Oct 2010 00:00:01 +0000
+Subject: ghosts
+Message-ID: $rmid
+From: Laggy Sender <lag\@example.com>
+To: list\@example.com
 
+are real
+EOF
         my $ghost_id = $rw->add_message($was_ghost);
         is($ghost_id, int($ghost_id), "ghost_id is an integer: $ghost_id");
         my $msgs = $rw->{over}->get_thread('ghost-message@s');
@@ -192,18 +189,17 @@ $ibx->with_umask(sub {
         $rw_commit->();
         $ro->reopen;
         my $long_mid = 'last' . ('x' x 60). '@s';
-
-        my $long = Email::MIME->create(
-                header_str => [
-                        Date => 'Sat, 02 Oct 2010 00:00:00 +0000',
-                        Subject => 'long message ID',
-                        'References' => '<root@s> <last@s>',
-                        'In-Reply-To' => '<last@s>',
-                        'Message-ID' => "<$long_mid>",
-                        From => '"Long I.D." <long-id@example.com>',
-                        To => 'list@example.com',
-                ],
-                body => "wut\n");
+        my $long = PublicInbox::MIME->new(<<EOF);
+Date: Sat, 02 Oct 2010 00:00:00 +0000
+Subject: long message ID
+References: <root\@s> <last\@s>
+In-Reply-To: <last\@s>
+Message-ID: <$long_mid>,
+From: "Long I.D." <long-id\@example.com>
+To: list\@example.com
+
+wut
+EOF
         my $long_id = $rw->add_message($long);
         is($long_id, int($long_id), "long_id is an integer: $long_id");
 
@@ -213,18 +209,16 @@ $ibx->with_umask(sub {
         my @res;
 
         my $long_reply_mid = 'reply-to-long@1';
-        my $long_reply = Email::MIME->create(
-                header_str => [
-                        Subject => 'I break references',
-                        Date => 'Sat, 02 Oct 2010 00:00:00 +0000',
-                        'Message-ID' => "<$long_reply_mid>",
-                        # No References:
-                        # 'References' => '<root@s> <last@s> <'.$long_mid.'>',
-                        'In-Reply-To' => "<$long_mid>",
-                        From => 'no1 <no1@example.com>',
-                        To => 'list@example.com',
-                ],
-                body => "no References\n");
+        my $long_reply = PublicInbox::MIME->new(<<EOF);
+Subject: I break references
+Date: Sat, 02 Oct 2010 00:00:00 +0000
+Message-ID: <$long_reply_mid>
+In-Reply-To: <$long_mid>
+From: no1 <no1\@example.com>
+To: list\@example.com
+
+no References
+EOF
         ok($rw->add_message($long_reply) > $long_id, "inserted long reply");
 
         $rw_commit->();
@@ -239,25 +233,26 @@ $ibx->with_umask(sub {
 # quote prioritization
 $ibx->with_umask(sub {
         $rw_commit->();
-        $rw->add_message(Email::MIME->create(
-                header_str => [
-                        Date => 'Sat, 02 Oct 2010 00:00:01 +0000',
-                        Subject => 'Hello',
-                        'Message-ID' => '<quote@a>',
-                        From => 'Quoter <quoter@example.com>',
-                        To => 'list@example.com',
-                ],
-                body => "> theatre illusions\nfade\n"));
-
-        $rw->add_message(Email::MIME->create(
-                header_str => [
-                        Date => 'Sat, 02 Oct 2010 00:00:02 +0000',
-                        Subject => 'Hello',
-                        'Message-ID' => '<nquote@a>',
-                        From => 'Non-Quoter<non-quoter@example.com>',
-                        To => 'list@example.com',
-                ],
-                body => "theatre\nfade\n"));
+        $rw->add_message(PublicInbox::MIME->new(<<'EOF'));
+Date: Sat, 02 Oct 2010 00:00:01 +0000
+Subject: Hello
+Message-ID: <quote@a>
+From: Quoter <quoter@example.com>
+To: list@example.com
+
+> theatre illusions
+fade
+EOF
+        $rw->add_message(PublicInbox::MIME->new(<<'EOF'));
+Date: Sat, 02 Oct 2010 00:00:02 +0000
+Subject: Hello
+Message-ID: <nquote@a>
+From: Non-Quoter<non-quoter@example.com>
+To: list@example.com
+
+theatre
+fade
+EOF
         my $res = $rw->query("theatre");
         is(scalar(@$res), 2, "got both matches");
         is($res->[0]->mid, 'nquote@a', "non-quoted scores higher") if scalar(@$res);
@@ -272,17 +267,17 @@ $ibx->with_umask(sub {
 # circular references
 $ibx->with_umask(sub {
         my $s = 'foo://'. ('Circle' x 15).'/foo';
-        my $doc_id = $rw->add_message(Email::MIME->create(
-                header => [ Subject => $s ],
-                header_str => [
-                        Date => 'Sat, 02 Oct 2010 00:00:01 +0000',
-                        'Message-ID' => '<circle@a>',
-                        'References' => '<circle@a>',
-                        'In-Reply-To' => '<circle@a>',
-                        From => 'Circle <circle@example.com>',
-                        To => 'list@example.com',
-                ],
-                body => "LOOP!\n"));
+        my $doc_id = $rw->add_message(PublicInbox::MIME->new(<<EOF));
+Subject: $s
+Date: Sat, 02 Oct 2010 00:00:01 +0000
+Message-ID: <circle\@a>
+References: <circle\@a>
+In-Reply-To: <circle\@a>
+From: Circle <circle\@example.com>
+To: list\@example.com
+
+LOOP!
+EOF
         ok($doc_id > 0, "doc_id defined with circular reference");
         my $smsg = $rw->query('m:circle@a', {limit=>1})->[0];
         is(defined($smsg), 1, 'found m:circl@a');
@@ -462,15 +457,13 @@ $ibx->with_umask(sub {
         my $mid = "$ua.$digits.2460-100000\@penguin.transmeta.com";
         is($ro->reopen->query("m:$digits", { mset => 1})->size, 0,
                 'no results yet');
-        my $pine = Email::MIME->create(
-                header_str => [
-                        Subject => 'blah',
-                        'Message-ID' => "<$mid>",
-                        From => 'torvalds@transmeta',
-                        To => 'list@example.com',
-                ],
-                body => ""
-        );
+        my $pine = PublicInbox::MIME->new(<<EOF);
+Subject: blah
+Message-ID: <$mid>
+From: torvalds\@transmeta
+To: list\@example.com
+
+EOF
         my $x = $rw->add_message($pine);
         $rw->commit_txn_lazy;
         is($ro->reopen->query("m:$digits", { mset => 1})->size, 1,
diff --git a/t/time.t b/t/time.t
index 94bf9181..71600b93 100644
--- a/t/time.t
+++ b/t/time.t
@@ -3,21 +3,20 @@
 use strict;
 use warnings;
 use Test::More;
-use_ok 'Email::MIME';
+use POSIX qw(strftime);
+use PublicInbox::MIME;
 use PublicInbox::MsgTime qw(msg_datestamp);
-my $mime = Email::MIME->create(
-        header => [
-                From => 'a@example.com',
-                To => 'test@example.com',
-                Subject => 'this is a subject',
-                'Message-ID' => '<a-mid@b>',
-                Date => 'Fri, 02 Oct 93 00:00:00 +0000',
-        ],
-        body => "hello world\n",
-);
+my $mime = PublicInbox::MIME->new(<<'EOF');
+From: a@example.com
+To: b@example.com
+Subject: this is a subject
+Message-ID: <a@example.com>
+Date: Fri, 02 Oct 1993 00:00:00 +0000
+
+hello world
+EOF
 
 my $ts = msg_datestamp($mime->header_obj);
-use POSIX qw(strftime);
 is(strftime('%Y-%m-%d %H:%M:%S', gmtime($ts)), '1993-10-02 00:00:00',
         'got expected date with 2 digit year');
 $mime->header_set(Date => 'Fri, 02 Oct 101 01:02:03 +0000');
diff --git a/t/v1-add-remove-add.t b/t/v1-add-remove-add.t
index c3a7e77f..23f4fb11 100644
--- a/t/v1-add-remove-add.t
+++ b/t/v1-add-remove-add.t
@@ -5,7 +5,8 @@ use warnings;
 use Test::More;
 use PublicInbox::Import;
 use PublicInbox::TestCommon;
-require_mods(qw(DBD::SQLite Search::Xapian Email::MIME));
+use PublicInbox::MIME;
+require_mods(qw(DBD::SQLite Search::Xapian));
 require PublicInbox::SearchIdx;
 my ($inboxdir, $for_destroy) = tmpdir();
 my $ibx = {
@@ -14,16 +15,15 @@ my $ibx = {
         -primary_address => 'test@example.com',
 };
 $ibx = PublicInbox::Inbox->new($ibx);
-my $mime = Email::MIME->create(
-        header => [
-                From => 'a@example.com',
-                To => 'test@example.com',
-                Subject => 'this is a subject',
-                Date => 'Fri, 02 Oct 1993 00:00:00 +0000',
-                'Message-ID' => '<a-mid@b>',
-        ],
-        body => "hello world\n",
-);
+my $mime = PublicInbox::MIME->new(<<'EOF');
+From: a@example.com
+To: test@example.com
+Subject: this is a subject
+Message-ID: <a-mid@b>
+Date: Fri, 02 Oct 1993 00:00:00 +0000
+
+hello world
+EOF
 my $im = PublicInbox::Import->new($ibx->git, undef, undef, $ibx);
 $im->init_bare;
 ok($im->add($mime), 'message added');
diff --git a/t/v1reindex.t b/t/v1reindex.t
index ce3833be..e473fe7c 100644
--- a/t/v1reindex.t
+++ b/t/v1reindex.t
@@ -6,8 +6,9 @@ use Test::More;
 use PublicInbox::ContentId qw(content_digest);
 use File::Path qw(remove_tree);
 use PublicInbox::TestCommon;
+use PublicInbox::MIME;
 require_git(2.6);
-require_mods(qw(DBD::SQLite Search::Xapian Email::MIME));
+require_mods(qw(DBD::SQLite Search::Xapian));
 use_ok 'PublicInbox::SearchIdx';
 use_ok 'PublicInbox::Import';
 my ($inboxdir, $for_destroy) = tmpdir();
@@ -17,15 +18,14 @@ my $ibx_config = {
         -primary_address => 'test@example.com',
         indexlevel => 'full',
 };
-my $mime = Email::MIME->create(
-        header => [
-                From => 'a@example.com',
-                To => 'test@example.com',
-                Subject => 'this is a subject',
-                Date => 'Fri, 02 Oct 1993 00:00:00 +0000',
-        ],
-        body => "hello world\n",
-);
+my $mime = PublicInbox::MIME->new(<<'EOF');
+From: a@example.com
+To: test@example.com
+Subject: this is a subject
+Date: Fri, 02 Oct 1993 00:00:00 +0000
+
+hello world
+EOF
 my $minmax;
 my $msgmap;
 my ($mark1, $mark2, $mark3, $mark4);
diff --git a/t/v2-add-remove-add.t b/t/v2-add-remove-add.t
index ca998334..60a869ee 100644
--- a/t/v2-add-remove-add.t
+++ b/t/v2-add-remove-add.t
@@ -3,9 +3,10 @@
 use strict;
 use warnings;
 use Test::More;
+use PublicInbox::MIME;
 use PublicInbox::TestCommon;
 require_git(2.6);
-require_mods(qw(DBD::SQLite Search::Xapian Email::MIME));
+require_mods(qw(DBD::SQLite Search::Xapian));
 use_ok 'PublicInbox::V2Writable';
 my ($inboxdir, $for_destroy) = tmpdir();
 my $ibx = {
@@ -15,16 +16,15 @@ my $ibx = {
         -primary_address => 'test@example.com',
 };
 $ibx = PublicInbox::Inbox->new($ibx);
-my $mime = Email::MIME->create(
-        header => [
-                From => 'a@example.com',
-                To => 'test@example.com',
-                Subject => 'this is a subject',
-                Date => 'Fri, 02 Oct 1993 00:00:00 +0000',
-                'Message-ID' => '<a-mid@b>',
-        ],
-        body => "hello world\n",
-);
+my $mime = PublicInbox::MIME->new(<<'EOF');
+From: a@example.com
+To: test@example.com
+Subject: this is a subject
+Date: Fri, 02 Oct 1993 00:00:00 +0000
+Message-ID: <a-mid@b>
+
+hello world
+EOF
 my $im = PublicInbox::V2Writable->new($ibx, 1);
 $im->{parallel} = 0;
 ok($im->add($mime), 'message added');
diff --git a/t/v2mda.t b/t/v2mda.t
index 94b63310..4d3ec30d 100644
--- a/t/v2mda.t
+++ b/t/v2mda.t
@@ -6,10 +6,11 @@ use Test::More;
 use Fcntl qw(SEEK_SET);
 use Cwd;
 use PublicInbox::TestCommon;
+use PublicInbox::MIME;
 require_git(2.6);
 
 my $V = 2;
-require_mods(qw(DBD::SQLite Search::Xapian Email::MIME));
+require_mods(qw(DBD::SQLite Search::Xapian));
 use_ok 'PublicInbox::V2Writable';
 my ($tmpdir, $for_destroy) = tmpdir();
 my $ibx = {
@@ -17,18 +18,16 @@ my $ibx = {
         name => 'test-v2writable',
         address => [ 'test@example.com' ],
 };
-my $mime = Email::MIME->create(
-        header => [
-                From => 'a@example.com',
-                To => 'test@example.com',
-                Subject => 'this is a subject',
-                Date => 'Fri, 02 Oct 1993 00:00:00 +0000',
-                'Message-ID' => '<foo@bar>',
-                'List-ID' => '<test.example.com>',
-        ],
-        body => "hello world\n",
-);
+my $mime = PublicInbox::MIME->new(<<'EOF');
+From: a@example.com
+To: test@example.com
+Subject: this is a subject
+Date: Fri, 02 Oct 1993 00:00:00 +0000
+Message-ID: <foo@bar>
+List-ID: <test.example.com>
 
+hello world
+EOF
 my $main_bin = getcwd()."/t/main-bin";
 my $fail_bin = getcwd()."/t/fail-bin";
 local $ENV{PI_DIR} = "$tmpdir/foo";
diff --git a/t/v2reindex.t b/t/v2reindex.t
index 7bf6bc2f..b97c6498 100644
--- a/t/v2reindex.t
+++ b/t/v2reindex.t
@@ -8,7 +8,7 @@ use PublicInbox::ContentId qw(content_digest);
 use File::Path qw(remove_tree);
 use PublicInbox::TestCommon;
 require_git(2.6);
-require_mods(qw(DBD::SQLite Search::Xapian Email::MIME));
+require_mods(qw(DBD::SQLite Search::Xapian));
 use_ok 'PublicInbox::V2Writable';
 my ($inboxdir, $for_destroy) = tmpdir();
 my $ibx_config = {
@@ -24,15 +24,13 @@ my $agpl = do {
         <$fh>;
 };
 my $phrase = q("defending all users' freedom");
-my $mime = Email::MIME->create(
-        header => [
-                From => 'a@example.com',
-                To => 'test@example.com',
-                Subject => 'this is a subject',
-                Date => 'Fri, 02 Oct 1993 00:00:00 +0000',
-        ],
-        body => $agpl,
-);
+my $mime = PublicInbox::MIME->new(<<'EOF'.$agpl);
+From: a@example.com
+To: test@example.com
+Subject: this is a subject
+Date: Fri, 02 Oct 1993 00:00:00 +0000
+
+EOF
 my $minmax;
 my $msgmap;
 my ($mark1, $mark2, $mark3, $mark4);
diff --git a/t/v2writable.t b/t/v2writable.t
index 7e7560b3..07687052 100644
--- a/t/v2writable.t
+++ b/t/v2writable.t
@@ -8,7 +8,7 @@ use PublicInbox::ContentId qw(content_digest content_id);
 use PublicInbox::TestCommon;
 use Cwd qw(abs_path);
 require_git(2.6);
-require_mods(qw(DBD::SQLite Search::Xapian Email::MIME));
+require_mods(qw(DBD::SQLite Search::Xapian));
 local $ENV{HOME} = abs_path('t');
 use_ok 'PublicInbox::V2Writable';
 umask 007;
@@ -20,17 +20,15 @@ my $ibx = {
         -primary_address => 'test@example.com',
 };
 $ibx = PublicInbox::Inbox->new($ibx);
-my $mime = Email::MIME->create(
-        header => [
-                From => 'a@example.com',
-                To => 'test@example.com',
-                Subject => 'this is a subject',
-                'Message-ID' => '<a-mid@b>',
-                Date => 'Fri, 02 Oct 1993 00:00:00 +0000',
-        ],
-        body => "hello world\n",
-);
+my $mime = PublicInbox::MIME->new(<<'EOF');
+From: a@example.com
+To: test@example.com
+Subject: this is a subject
+Message-ID: <a-mid@b>
+Date: Fri, 02 Oct 1993 00:00:00 +0000
 
+hello world
+EOF
 my $im = PublicInbox::V2Writable->new($ibx, {nproc => 1});
 is($im->{shards}, 1, 'one shard when forced');
 ok($im->add($mime), 'ordinary message added');
diff --git a/t/watch_maildir.t b/t/watch_maildir.t
index 9ed04cab..c34d15f7 100644
--- a/t/watch_maildir.t
+++ b/t/watch_maildir.t
@@ -2,7 +2,7 @@
 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
 use strict;
 use Test::More;
-use Email::MIME;
+use PublicInbox::MIME;
 use Cwd;
 use PublicInbox::Config;
 use PublicInbox::TestCommon;
diff --git a/t/xcpdb-reshard.t b/t/xcpdb-reshard.t
index 2571329e..0e1fea52 100644
--- a/t/xcpdb-reshard.t
+++ b/t/xcpdb-reshard.t
@@ -4,22 +4,19 @@ use strict;
 use warnings;
 use Test::More;
 use PublicInbox::TestCommon;
-require_mods(qw(DBD::SQLite Search::Xapian Email::MIME));
+require_mods(qw(DBD::SQLite Search::Xapian));
 require_git('2.6');
 use PublicInbox::MIME;
 use PublicInbox::InboxWritable;
 require PublicInbox::Search;
 
-my $mime = Email::MIME->create(
-        header => [
-                From => 'a@example.com',
-                To => 'test@example.com',
-                Subject => 'this is a subject',
-                Date => 'Fri, 02 Oct 1993 00:00:00 +0000',
-        ],
-        body => '',
-);
+my $mime = PublicInbox::MIME->new(<<'EOF');
+From: a@example.com
+To: test@example.com
+Subject: this is a subject
+Date: Fri, 02 Oct 1993 00:00:00 +0000
 
+EOF
 my ($this) = (split('/', $0))[-1];
 my ($tmpdir, $for_destroy) = tmpdir();
 local $ENV{PI_CONFIG} = "$tmpdir/config";