unshift @mimeparts, {
'Type' => ( $options{'content-type'} || 'text/plain' ),
'Charset' => 'UTF-8',
- 'Data' => $options{'body'},
+ 'Data' => ( $options{'content-type'} =~ /^text\//
+ ? Encode::encode_utf8( $options{'body'} )
+ : $options{'body'}
+ ),
'Encoding' => ( $options{'content-type'} ? '-SUGGEST' : '7bit' ),
'Disposition' => 'inline',
};
@mimeargs = (
'Type' => ( $options{'content-type'} || 'text/plain' ),
- 'Data' => $options{'body'},
+ 'Data' => ( $options{'content-type'} =~ /^text\//
+ ? Encode::encode_utf8( $options{'body'} )
+ : $options{'body'}
+ ),
'Encoding' => ( $options{'content-type'} ? '-SUGGEST' : '7bit' ),
'Charset' => 'UTF-8',
);
}
push @to, $options{bcc} if defined($options{bcc});
+ # fully unpack all addresses found in @to (including Bcc) to make the
+ # envelope list
+ my @env_to;
+ foreach my $dest (@to) {
+ push @env_to, map { $_->address } Email::Address->parse($dest);
+ }
+
local $@; # just in case
eval { sendmail($message, { transport => $transport,
from => $from,
- to => \@to }) };
+ to => \@env_to }) };
my $error = '';
if(ref($@) and $@->isa('Email::Sender::Failure')) {
if ( $conf->exists('log_sent_mail') ) {
my $cust_msg = FS::cust_msg->new({
'env_from' => $options{'from'},
- 'env_to' => join(', ', @to),
+ 'env_to' => join(', ', @env_to),
'header' => $message->header_as_string,
'body' => $message->body_as_string,
'_date' => $time,
'status' => ($error ? 'failed' : 'sent'),
'msgtype' => $options{'msgtype'},
});
- $cust_msg->insert; # ignore errors
+ my $log_error = $cust_msg->insert;
+ warn "Error logging message: $log_error\n" if $log_error; # at least warn
}
$error;
'Encoding' => 'quoted-printable',
'Charset' => 'UTF-8',
#'Encoding' => '7bit',
- 'Data' => $data,
+ 'Data' => Encode::encode_utf8($data),
'Disposition' => 'inline',
);
' </title>',
' </head>',
' <body bgcolor="#ffffff">',
- @html_data,
+ ( map Encode::encode_utf8($_), @html_data ),
' </body>',
'</html>',
],
}
-=item process_send_email OPTION => VALUE ...
-
-Takes arguments as per generate_email() and sends the message. This
-will die on any error and can be used in the job queue.
-
-=cut
-
-sub process_send_email {
- my %message = @_;
- my $error = send_email(generate_email(%message));
- die "$error\n" if $error;
- '';
-}
-
-=item process_send_generated_email OPTION => VALUE ...
-
-Takes arguments as per send_email() and sends the message. This
-will die on any error and can be used in the job queue.
-
-=cut
-
-sub process_send_generated_email {
- my %args = @_;
- my $error = send_email(%args);
- die "$error\n" if $error;
- '';
-}
-
=item send_fax OPTION => VALUE ...
Options:
sub states_hash {
my($country) = @_;
+ #a hash? not expecting an explosion of business from unrecognized countries..
+ return states_hash_nosubcountry($country) if $country eq 'XC';
+
my @states =
# sort
map { s/[\n\r]//g; $_; }
@states;
}
+sub states_hash_nosubcountry {
+ my($country) = @_;
+
+ my @states =
+# sort
+ map { s/[\n\r]//g; $_; }
+ map { $_->state; }
+ qsearch({
+ 'select' => 'state',
+ 'table' => 'cust_main_county',
+ 'hashref' => { 'country' => $country },
+ 'extra_sql' => 'GROUP BY state',
+ });
+
+ #"i see your schwartz is as big as mine!"
+ map { ( $_->[0] => $_->[1] ) }
+ sort { $a->[1] cmp $b->[1] }
+ map { [ $_ => $_ ] }
+ @states;
+}
+
=item counties STATE COUNTRY
Returns a list of counties for this state and country.
my $papersize = $conf->config('papersize') || 'letter';
+ local($SIG{CHLD}) = sub {};
+
system('dvips', '-q', '-t', $papersize, "$file.dvi", '-o', "$file.ps" ) == 0
or die "dvips failed";
#system('dvipdf', "$file.dvi", "$file.pdf" );
my $papersize = $conf->config('papersize') || 'letter';
+ local($SIG{CHLD}) = sub {};
+
system(
"dvips -q -f $sfile.dvi -t $papersize ".
"| gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=$sfile.pdf ".
: $conf->config('lpr', $opt{'agentnum'} );
my $outerr = '';
+ local($SIG{CHLD}) = sub {};
run3 $lpr, $data, \$outerr, \$outerr;
if ( $? ) {
$outerr = ": $outerr" if length($outerr);
print $fh $logo_data;
close $fh;
+ local($SIG{CHLD}) = sub {};
+
run( [qw(ocroscript recognize), $filename], '>'=>"$filename.hocr" )
or die "ocroscript recognize failed\n";