|
From: Chris W. <la...@us...> - 2001-10-28 02:41:02
|
Update of /cvsroot/openinteract/OpenInteract/OpenInteract
In directory usw-pr-cvs1:/tmp/cvs-serv9956/OpenInteract
Modified Files:
Utility.pm
Log Message:
use the new content_type object
Index: Utility.pm
===================================================================
RCS file: /cvsroot/openinteract/OpenInteract/OpenInteract/Utility.pm,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** Utility.pm 2001/10/17 04:47:07 1.3
--- Utility.pm 2001/10/28 02:41:00 1.4
***************
*** 13,48 ****
use constant DEFAULT_ATTACH_MESSAGE => 'Emailing attachments';
!
! my %ATTACH_TYPES = (
! csv => [ 'text/csv', '8bit' ],
! gif => [ 'image/gif', 'base64' ],
! tiff => [ 'image/tiff', 'base64' ],
! tif => [ 'image/tiff', 'base64' ],
! jpeg => [ 'image/jpeg', 'base64' ],
! jpg => [ 'image/jpeg', 'base64' ],
! png => [ 'image/png', 'base64' ],
! css => [ 'text/css', 'base64' ],
! html => [ 'text/html', '8bit' ],
! htm => [ 'text/html', '8bit' ],
! txt => [ 'text/plain', '8bit' ],
! xml => [ 'text/xml', '8bit' ],
! pdf => [ 'application/pdf', 'base64' ],
! doc => [ 'application/msword', 'base64' ],
! ps => [ 'application/postscript', 'base64' ],
! xls => [ 'application/vnd.ms-excel', 'base64' ],
! ppt => [ 'application/vnd.ms-powerpoint', 'base64' ],
! wpd => [ 'application/wordperfect', 'base64' ],
! js => [ 'application/x-javascript', '8bit' ],
! tar => [ 'application/x-tar', 'base64' ],
! zip => [ 'application/zip', 'base64' ],
! gz => [ 'application/gzip', 'base64' ],
! mp3 => [ 'audio/mpeg', 'base64' ],
! wav => [ 'audio/x-wav', 'base64' ],
! avi => [ 'video/x-msvideo', 'base64' ],
! mov => [ 'video/quicktime', 'base64' ],
! mpg => [ 'video/mpeg', 'base64' ],
! mpeg => [ 'video/mpeg', 'base64' ],
! );
sub send_email {
--- 13,21 ----
use constant DEFAULT_ATTACH_MESSAGE => 'Emailing attachments';
! # All other types except those listed here are 'base64' encoding
+ my %TEXT_ENCODINGS = map { $_ => '8bit' }
+ qw( text/csv text/html text/html text/plain text/xml
+ application/x-javascript application/x-perl );
sub send_email {
***************
*** 80,83 ****
--- 53,58 ----
return $class->send_email( $p ) unless ( scalar @{ $attachments } > 0 );
+ my $R = OpenInteract::Request->instance;
+
my %header_info = $class->_build_header_info( $p );
my $initial_text = $p->{message} || DEFAULT_ATTACH_MESSAGE;
***************
*** 89,95 ****
next unless ( $cleaned_name );
my ( $ext ) = $cleaned_name =~ /\.(\w+)$/;
! my $type = $ATTACH_TYPES{ lc $ext } || [ 'text/plain', '8bit' ];
! $msg->attach( Type => $type->[0],
! Encoding => $type->[1],
Path => $cleaned_name );
}
--- 64,71 ----
next unless ( $cleaned_name );
my ( $ext ) = $cleaned_name =~ /\.(\w+)$/;
! my $mime_type = $R->content_type->mime_type_by_extension( lc $ext );
! my $encoding = $TEXT_ENCODINGS{ $mime_type } || 'base64';
! $msg->attach( Type => $mime_type,
! Encoding => $encoding,
Path => $cleaned_name );
}
|