On 11/18/2011 03:15 PM, Nathan Findley wrote:

Hi all,

How would I save an eml attachment on an incoming mail? Does this look
reasonable on a basic level?

sub filter_multipart ($$$$) {
my($entity, $fname, $ext, $type) = @_;

open FH, ">/tmp/copy.eml" or die $!;
if (re_match($entity, '\.eml') and ($type eq "message/rfc822")) {
$entity->print_body(FH);
}
close FH;
}


This is what I ended up doing:

if (re_match($entity, '\.eml') and ($type eq "message/rfc822")) {
my $inputmsg = "$CWD/NMS";
open FH, ">$inputmsg" or return action_bounce('IO ERROR '.__PACKAGE__.' '.__LINE__);
$entity->print(FH);
close FH;
system("/bin/sed -i 1,2d $inputmsg");
}

I am using sed because printing the contents of the entity leaves a couple of lines at the top of the resulting file that will cause mail readers to not recognize the file as a proper eml. If there is a way to immediately write to disk without those two top lines, it would be nice to know.

Thanks,
Nate

--
システムマネージャー/開発責任者
Zenlok株式会社

_______________________________________________
NOTE: If there is a disclaimer or other legal boilerplate in the above
message, it is NULL AND VOID.  You may ignore it.

Visit http://www.mimedefang.org and http://www.roaringpenguin.com
MIMEDefang mailing list [email protected]
http://lists.roaringpenguin.com/mailman/listinfo/mimedefang

Reply via email to