diff options
author | tetragon <tetragon@4979c152-3d1c-0410-bac9-87ea11338e46> | 2007-10-17 21:12:50 +0000 |
---|---|---|
committer | tetragon <tetragon@4979c152-3d1c-0410-bac9-87ea11338e46> | 2007-10-17 21:12:50 +0000 |
commit | b31d6b0e52b43fd0a3a1b6bdc8d5579d8cc22b58 (patch) | |
tree | 6e0eed63b32d959705dbcdbee800d1f49c8b01ec | |
parent | 9e55ef40f56ed124d02fe34c402e8ecc3fd55ae5 (diff) |
Mailer cleanups
git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@1777 4979c152-3d1c-0410-bac9-87ea11338e46
-rw-r--r-- | LedgerSMB/Mailer.pm | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/LedgerSMB/Mailer.pm b/LedgerSMB/Mailer.pm index 80ffebb8..473fa7cb 100644 --- a/LedgerSMB/Mailer.pm +++ b/LedgerSMB/Mailer.pm @@ -51,33 +51,37 @@ sub send { my ($self) = @_; my $domain = $self->{from}; + my $boundary = time; + $boundary = "LSMB-$boundary"; $domain =~ s/(.*?\@|>)//g; - my $msgid = "$boundary\@$domain"; + my $msg_id = "$boundary\@$domain"; $self->{contenttype} = "text/plain" unless $self->{contenttype}; - my %h; for (qw(from to cc bcc)) { $self->{$_} =~ s/\</</g; $self->{$_} =~ s/\>/>/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 @@ sub send { ( $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', |