# this script generates very deeply nested mime messages # to see how various mail clients handle this # use strict; use Digest::MD5 qw(md5_hex); sub genrandom { open(RNG, "openssl rand 16|") or die "rng:$!\n"; binmode RNG; my $data; read(RNG, $data, 16); close RNG; return $data; } sub genid { return md5_hex(pack("a*V", @_)); } my $maxdepth=shift; my $key= genrandom(); printf("Subject: multi %d %s\n", $maxdepth, unpack("H*", $key)); writemp("0"); sub writemp { my $path=shift; my $id= md5_hex($key.$path); printf("Content-Type: multipart/mixed; boundary=%s\n", $id); printf("\n"); printf("--%s\n", $id); printf("Content-Type: text/plain\n"); printf("\n"); printf(".... content A of %s\n", $path); printf("\n"); if (length($path)<2*$maxdepth) { printf("--%s\n", $id); writemp("$path.0"); printf("\n"); printf("--%s\n", $id); printf("Content-Type: text/plain\n"); printf("\n"); printf(".... content B of %s\n", $path); printf("\n"); printf("--%s\n", $id); writemp("$path.1"); printf("\n"); } printf("--%s\n", $id); printf("Content-Type: text/plain\n"); printf("\n"); printf(".... content C of %s\n", $path); printf("\n"); printf("--%s--\n", $id); printf("\n"); }