=item cust_main
-Customer object (required).
+Customer object
=item object
body of the message. This should be used ONLY by L<FS::report_batch> and may
go away in the future.
+=item attach
+
+A L<MIME::Entity> (or arrayref of them) to attach to the message.
+
+=cut
+
=back
=cut
my( $self, %opt ) = @_;
my $cust_main = $opt{'cust_main'}; # or die 'cust_main required';
- my $object = $opt{'object'} or die 'object required';
+ my $object = $opt{'object'}; # or die 'object required';
my $hashref = $self->prepare_substitutions(%opt);
'Type' => 'multipart/related',
);
+ if ( $opt{'attach'} ) {
+ my @attach;
+ if (ref $opt{'attach'} eq 'ARRAY') {
+ @attach = @{ $opt{'attach'} };
+ } else {
+ @attach = $opt{'attach'};
+ }
+ foreach (@attach) {
+ $message->add_part($_);
+ }
+ }
+
#$message->head->replace('Content-type',
# 'multipart/related; '.
# 'boundary="' . $message->head->multipart_boundary . '"; ' .
# 'type=multipart/alternative'
#);
-
- # XXX a facility to attach additional parts is necessary at some point
+
foreach my $part (@{ $email{mimeparts} }) {
warn "$me appending part ".$part->mime_type."\n" if $DEBUG;
$message->add_part( $part );
my $env_to = join(', ', @to);
my $cust_msg = FS::cust_msg->new({
- 'custnum' => $cust_main->custnum,
+ 'custnum' => $cust_main ? $cust_main->custnum : '',
'msgnum' => $self->msgnum,
'_date' => $time,
'env_from' => $env_from,