[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SF.net SVN: ledger-smb: [1777] trunk/LedgerSMB/Mailer.pm



Revision: 1777
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=1777&view=rev
Author:   tetragon
Date:     2007-10-17 14:12:50 -0700 (Wed, 17 Oct 2007)

Log Message:
-----------
Mailer cleanups

Modified Paths:
--------------
    trunk/LedgerSMB/Mailer.pm

Modified: trunk/LedgerSMB/Mailer.pm
===================================================================
--- trunk/LedgerSMB/Mailer.pm	2007-10-17 21:12:29 UTC (rev 1776)
+++ trunk/LedgerSMB/Mailer.pm	2007-10-17 21:12:50 UTC (rev 1777)
@@ -51,33 +51,37 @@
     my ($self) = @_;
 
     my $domain = $self->{from};
+    my $boundary = time;
+    $boundary = "LSMB-$boundary";
     $domain =~ s/(.*?\@|>)//g;
-    my $msgid = "..hidden..";
+    my $msg_id = "..hidden..";
 
     $self->{contenttype} = "text/plain" unless $self->{contenttype};
 
-    my %h;
     for (qw(from to cc bcc)) {
         $self->{$_} =~ s/\&lt;/</g;
         $self->{$_} =~ s/\&gt;/>/g;
         $self->{$_} =~ s/(\/|\\|\$)//g;
-        $h{$_} = $self->{$_};
     }
 
-    $h{subject} = "Subject: ".Encode::encode('MIME-Header', $self->{subject});
-
     my $msg = MIME::Lite->new(
         'From'    => $self->{from},
         'To'      => $self->{to},
         'Cc'      => $self->{cc},
         'Bcc'     => $self->{bcc},
-        'Subject' => $self->{subject},
+        'Subject' => Encode::encode('MIME-Header', $self->{subject}),
         'Type'    => 'TEXT',
-        'Data'    => $self->{message},
+        'Data'    => Encode::encode_utf8($self->{message}),
+        'Encoding'    => '8bit',
+        'Message-ID'    => $msg_id,
     );
+    $msg->attr( 'Content-Type' => $self->{contenttype} );
+    $msg->attr( 'Content-Type.charset' => 'UTF-8' ) if
+        $self->{contenttype} =~ m#^text/#;
     $msg->add( 'Disposition-Notification-To' => $self->{from} )
       if $self->{notify};
     $msg->replace( 'X-Mailer' => "LedgerSMB $self->{version}" );
+    $msg->binmode(':utf8');
 
     if ( @{ $self->{attachments} } ) {
         foreach my $attachment ( @{ $self->{attachments} } ) {
@@ -86,13 +90,15 @@
               ( $attachment =~ /(^\w+$)|\.(html|text|txt|sql)$/ )
               ? "text"
               : "application";
+            my $type = "$attachment/$self->{format}";
+            $type .= '; charset="UTF-8"' if $attachment eq 'text';
 
             my $filename = $attachment;
 
             # strip path
             $filename =~ s/(.*\/|$self->{fileid})//g;
             $msg->attach(
-                'Type'        => "$application/$self->{format}",
+                'Type'        => $type,
                 'Path'        => $attachment,
                 'Filename'    => $filename,
                 'Disposition' => 'attachment',


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.