X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;ds=sidebyside;f=FS%2FFS%2FMisc.pm;h=2e383d549274db5150de269a76a4c653324b0e0d;hb=2aa5c02ab333809f44d74140249fbf610233c0fd;hp=92780f7076ebe050f570365ca108fb06fc7c7f30;hpb=3081639bd119c6d281ef23139649b2e73ba62754;p=freeside.git diff --git a/FS/FS/Misc.pm b/FS/FS/Misc.pm index 92780f707..2e383d549 100644 --- a/FS/FS/Misc.pm +++ b/FS/FS/Misc.pm @@ -4,11 +4,12 @@ use strict; use vars qw ( @ISA @EXPORT_OK $DEBUG ); use Exporter; use Carp; +use Data::Dumper; @ISA = qw( Exporter ); @EXPORT_OK = qw( send_email send_fax ); -$DEBUG = 1; +$DEBUG = 0; =head1 NAME @@ -69,6 +70,12 @@ FS::UID->install_callback( sub { sub send_email { my(%options) = @_; + if ( $DEBUG ) { + my %doptions = %options; + $doptions{'body'} = '(full body not shown in debug)'; + warn "FS::Misc::send_email called with options:\n ". Dumper(\%doptions); +# join("\n", map { " $_: ". $options{$_} } keys %options ). "\n" + } $ENV{MAILADDRESS} = $options{'from'}; my $to = ref($options{to}) ? join(', ', @{ $options{to} } ) : $options{to}; @@ -118,8 +125,15 @@ sub send_email { } - $options{'from'} =~ /\@([\w\.\-]+)/ or $1 = 'example.com'; - my $message_id = join('.', rand()*(2**32), $$, time). "\@$1"; + my $domain; + if ( $options{'from'} =~ /\@([\w\.\-]+)/ ) { + $domain = $1; + } else { + warn 'no domain found in invoice from address '. $options{'from'}. + '; constructing Message-ID @example.com'; + $domain = 'example.com'; + } + my $message_id = join('.', rand()*(2**32), $$, time). "\@$domain"; my $message = MIME::Entity->build( 'From' => $options{'from'}, @@ -245,13 +259,13 @@ sub send_fax { if ($faxjob->success) { warn "Successfully queued fax to '$options{dialstring}' with jobid " . - $faxjob->jobid; + $faxjob->jobid + if $DEBUG; + return ''; } else { return 'Error while sending FAX: ' . $faxjob->trace; } - return ''; - } package Mail::Internet; @@ -326,6 +340,8 @@ sub Mail::Internet::mysmtpsend { } package FS::Misc; +=back + =head1 BUGS This package exists.