Using Catalyst::View::Email::Template is great for separating presentation
from data in generating emails, but we're running into Server issues when
the email includes a large attachment (or several). The whole email gets
built in server ram before the response comes back to the browser.

Is there a (straightforward, hopefully :) way to buffer large attachments
when generating emails via a Catalyst View?

$att = $item->attachments_rs;
if ( $att->count ) {
    my @parts;
    require Email::MIME;
    while ( my $fyl = $att->next ) {

        my $part = Email::MIME->create(
            attributes => {
                filename     => $fyl->path,
                name         => $fyl->path,
                content_type => $fyl->mimetype,
                disposition  => 'attachment',
                encoding     => 'base64',
            },
            # body => read_entire_file( *$fyl->path_to_file* ), # ugh!
*            body => $fyl->path_to_file, # or $filehandle*
        );
        push @parts, $part;

    }
    $email_args{parts} = [ @parts ];
}
$c->stash( email => { %email_args } );
$c->forward( 'View::Email' );

If we could use a combination of Template-Toolkit and Email::Stuff which
handles buffering nicely (hand it a $FH instead of content, swee-ee-eet)
that would be grand. It doesn't look like Email::MIME (which
Catalyst::View::Email builds upon) doesn't seem to expect anything other
than $body_content.


-- 
"We act as though comfort and luxury were the chief requirements of life,
when all that we need to make us happy is something to be enthusiastic
about." -- Albert Einstein
_______________________________________________
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/

Reply via email to