summaryrefslogtreecommitdiff
path: root/LedgerSMB/Mailer.pm
diff options
context:
space:
mode:
Diffstat (limited to 'LedgerSMB/Mailer.pm')
-rw-r--r--LedgerSMB/Mailer.pm152
1 files changed, 76 insertions, 76 deletions
diff --git a/LedgerSMB/Mailer.pm b/LedgerSMB/Mailer.pm
index 05a711bd..eb1d4a9b 100644
--- a/LedgerSMB/Mailer.pm
+++ b/LedgerSMB/Mailer.pm
@@ -1,5 +1,5 @@
#=====================================================================
-# LedgerSMB
+# LedgerSMB
# Small Medium Business Accounting software
# http://www.ledgersmb.org/
#
@@ -19,7 +19,7 @@
# Author: DWS Systems Inc.
# Web: http://www.sql-ledger.org
#
-# Contributors:
+# Contributors:
#
# Original Author and copyright holder:
# Dieter Simader dsmimader@sql-ledger.com
@@ -40,85 +40,85 @@ use MIME::Base64;
use LedgerSMB::Sysconfig;
sub new {
- my ($type) = @_;
- my $self = {};
+ my ($type) = @_;
+ my $self = {};
- bless $self, $type;
+ bless $self, $type;
}
-
sub send {
- my ($self) = @_;
-
- my $domain = $self->{from};
- $domain =~ s/(.*?\@|>)//g;
- my $msgid = "$boundary\@$domain";
-
-
- $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} =
- ($self->{subject} =~ /([\x00-\x1F]|[\x7B-\xFFFF])/)
- ? "Subject: =?$self->{charset}?B?".
- MIME::Base64::encode($self->{subject},"")."?="
- : "Subject: $self->{subject}";
-
- my $msg = MIME::Lite->new(
- 'From' => $self->{from},
- 'To' => $self->{to},
- 'Cc' => $self->{cc},
- 'Bcc' => $self->{bcc},
- 'Subject' => $self->{subject},
- 'Type' => 'TEXT',
- 'Data' => $self->{message},
- );
- $msg->add('Disposition-Notification-To' => $self->{from})
- if $self->{notify};
- $msg->replace('X-Mailer' => "LedgerSMB $self->{version}");
-
- if (@{ $self->{attachments} }) {
- foreach my $attachment (@{ $self->{attachments} }) {
-
- my $application =
- ($attachment =~
- /(^\w+$)|\.(html|text|txt|sql)$/)
- ? "text"
- : "application";
-
- my $filename = $attachment;
- # strip path
- $filename =~ s/(.*\/|$self->{fileid})//g;
- $msg->attach(
- 'Type' => "$application/$self->{format}",
- 'Path' => $attachment,
- 'Filename' => $filename,
- 'Disposition' => 'attachment',
- );
- }
-
- }
-
- if (${LedgerSMB::Sysconfig::smtphost}) {
- $msg->send('smtp', ${LedgerSMB::Sysconfig::smtphost},
- Timeout => ${LedgerSMB::Sysconfig::smtptimeout}) ||
- return $!;
- } else {
- $msg->send('sendmail', ${LedgerSMB::Sysconfig::sendmail}) ||
- return $!;
- }
-
- return "";
-
-}
+ my ($self) = @_;
+
+ my $domain = $self->{from};
+ $domain =~ s/(.*?\@|>)//g;
+ my $msgid = "$boundary\@$domain";
+
+ $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} =
+ ( $self->{subject} =~ /([\x00-\x1F]|[\x7B-\xFFFF])/ )
+ ? "Subject: =?$self->{charset}?B?"
+ . MIME::Base64::encode( $self->{subject}, "" ) . "?="
+ : "Subject: $self->{subject}";
+
+ my $msg = MIME::Lite->new(
+ 'From' => $self->{from},
+ 'To' => $self->{to},
+ 'Cc' => $self->{cc},
+ 'Bcc' => $self->{bcc},
+ 'Subject' => $self->{subject},
+ 'Type' => 'TEXT',
+ 'Data' => $self->{message},
+ );
+ $msg->add( 'Disposition-Notification-To' => $self->{from} )
+ if $self->{notify};
+ $msg->replace( 'X-Mailer' => "LedgerSMB $self->{version}" );
+
+ if ( @{ $self->{attachments} } ) {
+ foreach my $attachment ( @{ $self->{attachments} } ) {
+
+ my $application =
+ ( $attachment =~ /(^\w+$)|\.(html|text|txt|sql)$/ )
+ ? "text"
+ : "application";
+
+ my $filename = $attachment;
+
+ # strip path
+ $filename =~ s/(.*\/|$self->{fileid})//g;
+ $msg->attach(
+ 'Type' => "$application/$self->{format}",
+ 'Path' => $attachment,
+ 'Filename' => $filename,
+ 'Disposition' => 'attachment',
+ );
+ }
+
+ }
+
+ if ( ${LedgerSMB::Sysconfig::smtphost} ) {
+ $msg->send(
+ 'smtp',
+ ${LedgerSMB::Sysconfig::smtphost},
+ Timeout => ${LedgerSMB::Sysconfig::smtptimeout}
+ ) || return $!;
+ }
+ else {
+ $msg->send( 'sendmail', ${LedgerSMB::Sysconfig::sendmail} )
+ || return $!;
+ }
+
+ return "";
+}
1;