aboutsummaryrefslogtreecommitdiffstats
path: root/t/delivert
diff options
context:
space:
mode:
Diffstat (limited to 't/delivert')
-rwxr-xr-xt/delivert25
1 files changed, 25 insertions, 0 deletions
diff --git a/t/delivert b/t/delivert
new file mode 100755
index 0000000..63c3864
--- /dev/null
+++ b/t/delivert
@@ -0,0 +1,25 @@
+#!/usr/bin/perl
+
+use Email::Simple;
+use IO::File;
+
+use strict;
+use warnings;
+
+die usage() unless $#ARGV == 0;
+my $path = shift;
+
+local $/;
+my $email = Email::Simple->new(<>);
+
+my $msgid = $email->header('Message-ID');
+$msgid =~ s/<(.*)@.*>/$1/;
+
+my $fh = IO::File->new(">$path/$msgid") ||
+ die "Couldn't write to $path/$msgid: $!\n";
+print $fh $email->as_string;
+$fh->close;
+
+sub usage {
+ "Usage: $0 path\n";
+}