[Catalyst] Catalyst generating emails -- how to buffer large attachments?

will trillich will.trillich at serensoft.com
Tue Dec 20 21:20:08 GMT 2011


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 =3D $item->attachments_rs;
if ( $att->count ) {
    my @parts;
    require Email::MIME;
    while ( my $fyl =3D $att->next ) {

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

    }
    $email_args{parts} =3D [ @parts ];
}
$c->stash( email =3D> { %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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20111220/d4af3=
7a2/attachment.htm


More information about the Catalyst mailing list