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
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};
}
- $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'},
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;
}
package FS::Misc;
+=back
+
=head1 BUGS
This package exists.