Index: mail-in.pl
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/og2list/mail-in.pl,v
retrieving revision 1.31
diff -u -p -r1.31 mail-in.pl
--- mail-in.pl	24 Aug 2006 19:35:21 -0000	1.31
+++ mail-in.pl	14 Nov 2006 19:57:17 -0000
@@ -1,6 +1,6 @@
 #!/usr/bin/perl -w
 
-# $Id: mail-in.pl,v 1.31 2006/08/24 19:35:21 bengen Exp $
+# $Id: mail-in.pl,v 1.27.2.1 2006/08/31 08:20:41 killes Exp $
 
 # THIS IS PROTOTYPE CODE AND SHOULD NOT BE USED IN PRODUCTION SYSTEMS!
 
@@ -231,6 +231,8 @@ use DBI;
 use Getopt::Std;
 use Encode qw(decode);
 
+use File::Basename 'basename';
+
 use vars qw(
 	    $dsn $dbh
 
@@ -405,16 +407,29 @@ EOF
 }
 
 # ----------------------------------------------------------------------
+sub save_attachment(@) {
+  my $entity = shift;
+  my $name = $entity->head()->recommended_filename;
+  my $type = $entity->effective_type;
+
+  my $filename = basename $name;
+  my $attachment = File::Spec->catfile('/tmp', $filename);
+
+  unless( -f $attachment ) {
+      open( FH, ">$attachment");
+      $entity->bodyhandle->print(\*FH);
+      close(FH);
+  }
+
+  $entity->delete;
+}
+
+# ----------------------------------------------------------------------
 
 sub simplify_body($) {
   my $entity = shift;
   my $body;
 
-  # Skip attachments
-  return if (defined $entity->head()->mime_attr('content-disposition') &&
-	     $entity->head()->mime_attr('content-disposition') =~
-	     /attachment/);
-
   foreach ($entity->mime_type) {
     chomp;
 
@@ -437,7 +452,7 @@ sub simplify_body($) {
 	if ($type =~ /^text/) {
 	  next if (exists $alternative{$type});
 	  $alternative{$type}=$body;
-	}
+        }
       }
       if ($alternative{'text/html'}) {
 	return 'text/html', $alternative{'text/html'};
@@ -460,6 +475,12 @@ sub simplify_body($) {
 	if ($type =~ /^text/) {
 	  $alternative{$type}.=$body;
 	}
+        else {
+            # For all non-text based components
+            # store the attachments for use by
+            # mail-out
+            save_attachment( $part );
+        }
       }
       if ($alternative{'text/html'}) {
 	return 'text/html', $alternative{'text/html'};
@@ -477,8 +498,6 @@ sub simplify_body($) {
     # RfC 2046, Section 5.1.7
     m/^multipart\/(.*)$/ && do {
     };
-
-    warn "FIXME: $_ MIME type not implemented yet";
   }
   return undef;
 }
