debugging output change in send_email
[freeside.git] / FS / FS / Misc.pm
index 74f73a2..98490ac 100644 (file)
@@ -4,6 +4,7 @@ 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 );
@@ -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};
@@ -122,6 +129,8 @@ sub send_email {
   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";