X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fmsg_template%2Femail.pm;h=07a1fa0934d304916e3f7b05ee587572ee746407;hb=fad183c519f7d8b7c905708efc984c571b2c2990;hp=377dbb17b45715090514401c3cac9a61bb7eb615;hpb=2b2dd969f3c18751afc583ad1e836ab8e6f73b5d;p=freeside.git diff --git a/FS/FS/msg_template/email.pm b/FS/FS/msg_template/email.pm index 377dbb17b..07a1fa093 100644 --- a/FS/FS/msg_template/email.pm +++ b/FS/FS/msg_template/email.pm @@ -164,7 +164,7 @@ Options are passed as a list of name/value pairs: =item cust_main -Customer object (required). +Customer object =item object @@ -206,6 +206,12 @@ A string to use as the HTML body; if specified, replaces the entire body of the message. This should be used ONLY by L and may go away in the future. +=item attach + +A L (or arrayref of them) to attach to the message. + +=cut + =back =cut @@ -215,7 +221,7 @@ sub prepare { 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); @@ -348,13 +354,24 @@ sub prepare { '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 ); @@ -365,7 +382,7 @@ sub prepare { 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,