[Affelio-cvs 1028] CVS update: affelio/lib/Affelio/NetLib

Back to archive index

Yoshihisa Fukuhara higef****@users*****
2006年 1月 5日 (木) 17:17:02 JST


Index: affelio/lib/Affelio/NetLib/Email.pm
diff -u affelio/lib/Affelio/NetLib/Email.pm:1.9 affelio/lib/Affelio/NetLib/Email.pm:1.10
--- affelio/lib/Affelio/NetLib/Email.pm:1.9	Fri Nov 18 20:18:32 2005
+++ affelio/lib/Affelio/NetLib/Email.pm	Thu Jan  5 17:17:02 2006
@@ -14,7 +14,7 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #
-# $Id: Email.pm,v 1.9 2005/11/18 11:18:32 slash5234 Exp $
+# $Id: Email.pm,v 1.10 2006/01/05 08:17:02 higefuku Exp $
 
 package Affelio::NetLib::Email; 
 {
@@ -38,11 +38,23 @@
 	my $to = shift;
 	my $subject = shift;
 	my $body = shift;
+	my $filename = shift;
+	my $attach = shift;
+	my $boundary = "-*-*-*-*-*-*-*-*-Boundary_" . time . "_" . $$;
 
 	my $eol = "";
 	my $subject_b = MIME::Base64::Perl::encode_base64($subject, $eol);
 	$subject_b = "=?utf-8?B?" . $subject_b . "?=";
-	my $headers = "From: $from_name <$from_addr>\nMIME-Version: 1.0\nContent-Type: text/plain; charset=utf-8\nContent-Transfer-Encoding: base64\n";
+	my $headers = "From: $from_name <$from_addr>\nMIME-Version: 1.0\n";
+	if ($attach ne "" && $filename ne ""){
+	    $filename = MIME::Base64::Perl::encode_base64($filename, $eol);
+	    $filename = "=?utf-8?B?" . $filename . "?=";
+	    $attach = MIME::Base64::Perl::encode_base64($attach);
+	    $headers .= "Content-Type: Multipart/Mixed; boundary=\"$boundary\"\n";
+	}else{
+	    $headers .= "Content-Type: text/plain; charset=utf-8\n";
+	}
+	$headers .= "Content-Transfer-Encoding: base64\n";
 	my $body_b = MIME::Base64::Perl::encode_base64($body);
 
         ###########################################
@@ -52,7 +64,23 @@
 	print MAIL $headers;
 	print MAIL "To: $to\n";
 	print MAIL "Subject: $subject_b\n\n";
+	if ($attach ne "" && $filename ne ""){
+	    print MAIL "--$boundary\n";
+	    print MAIL "Content-Type: text/plain; charset=utf-8\n";
+	    print MAIL "Content-Transfer-Encoding: base64\n";
+	    print MAIL "\n"
+	}
 	print MAIL "$body_b\n";
+	if ($attach ne "" && $filename ne ""){
+	    print MAIL "--$boundary\n";
+	    print MAIL "Content-Type: application/octet-stream; name=\"$filename\"\n";
+	    print MAIL "Content-Transfer-Encoding: base64\n";
+	    print MAIL "Content-Disposition: attachment; filename=\"$filename\"\n";
+	    print MAIL "\n";
+	    print MAIL "$attach\n";
+	    print MAIL "\n";
+	    print MAIL "--$boundary" . "--";
+	}
 	print MAIL "\n";
 	close(MAIL);
     }


Affelio-cvs メーリングリストの案内
Back to archive index