[interchange-cvs] interchange - racke modified lib/Vend/Email.pm

interchange-cvs at icdevgroup.org interchange-cvs at icdevgroup.org
Thu Dec 13 10:38:13 EST 2007


User:      racke
Date:      2007-12-13 15:38:13 GMT
Modified:  lib/Vend Email.pm
Log:
respect new "charset" parameter for [email], allows sending UTF-8 emails

Revision  Changes    Path
1.6       +29 -17    interchange/lib/Vend/Email.pm


rev 1.6, prev_rev 1.5
Index: Email.pm
===================================================================
RCS file: /var/cvs/interchange/lib/Vend/Email.pm,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- Email.pm	18 Oct 2007 19:33:25 -0000	1.5
+++ Email.pm	13 Dec 2007 15:38:12 -0000	1.6
@@ -1,6 +1,6 @@
 # Vend::Email - Handle Interchange email functions
 # 
-# $Id: Email.pm,v 1.5 2007/10/18 19:33:25 racke Exp $
+# $Id: Email.pm,v 1.6 2007/12/13 15:38:12 racke Exp $
 #
 # Copyright (C) 2007 Interchange Development Group
 #
@@ -55,7 +55,7 @@
 
 use vars qw/$VERSION/;
 
-$VERSION = substr(q$Revision: 1.5 $, 10);
+$VERSION = substr(q$Revision: 1.6 $, 10);
 
 
 ###########################################################################
@@ -841,17 +841,13 @@
 	my ($to, $subject, $reply, $from, $extra, $opt, $body) = @_;
 	my $ok = 0;
 	my @extra;
-
+	my $att;
+	
 	use vars qw/ $Tag /;
-
-
-	my $att = $opt->{attach};
-	ATTACH: {
-		
-		my %att_hash;
-
+	
+		ATTACH: {
 		#::logDebug("Checking for attachment");
-		last ATTACH unless $opt->{attach} || $opt->{html};
+		last ATTACH unless $opt->{attach} || $opt->{html} || ($opt->{charset} && $body =~ /\S/);
 
 		if($opt->{html}) {
 			$opt->{mimetype} ||= 'multipart/alternative';
@@ -860,16 +856,32 @@
 			$opt->{mimetype} ||= 'multipart/mixed';
 		}
 
-		if(! ref($att) ) {
-			my $fn = $att;
-			$att = [ { path => $fn } ];
+		my $vtype = ref($opt->{attach});
+
+		if ($vtype) {
+			if ($vtype eq 'HASH') {
+				$att = [ $opt->{attach} ];
+			}
+			elsif ($vtype eq 'ARRAY') {
+				$att = $opt->{attach};
+			}
 		}
-		elsif(ref($att) eq 'HASH') {
-			$att = [ $att ];
+		else {
+			if ($opt->{attach}) {
+				$att = [ { path => $opt->{attach} } ];
+			}
 		}
-
+		
 		$att ||= [];
 
+		if ($opt->{charset} && $body =~ /\S/) {
+			unshift @$att, {
+				type => "text/plain; charset=$opt->{charset}",
+				data => $body
+			};
+			$body = '';
+		}
+		
 		if($opt->{html}) {
 			unshift @$att, {
 				type => 'text/html',








More information about the interchange-cvs mailing list