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

will trillich will.trillich at serensoft.com
Fri Dec 23 20:08:26 GMT 2011


Thanks for the pointer, t0m!

We switched to Mail::Sender -- it opens a connection to the SMTP server
immediately, and pipes the output generating on -the-fly, instead of
accumulating beaucoup megabytes in RAM to then ship off the whole thing at
once.

Wound up doing as you suggested:
   use base 'Catalyst::View::TT';
   use Email::MIME;
   use Mail::Sender; # <=3D woo hoo!
   use Moose;

   sub render { ... }

And within render() we purloined chunks of the templating approach
(generate_part) from Catalyst::View::Email::Template in order to still use
the templates approach (one for HTML, one for text).

Works a treat!



On Wed, Dec 21, 2011 at 11:34 AM, Tomas Doran <bobtfish at bobtfish.net> wrote:

>
> On 20 Dec 2011, at 21:20, will trillich wrote:
>
>> Is there a (straightforward, hopefully :) way to buffer large attachments
>> when generating emails via a Catalyst View?
>>
>
> Yes, in the view code :_)
>
> But you don't mean this, you mean 'in Catalyst::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.
>>
>
> Time to not be using Catalyst::View::EMail then :)
>
> I'd recommend just sub-classing either your existing (or a new) TT view,
> and using around render =3D> sub {... to do whatever you want with
> Email::Stuff, taking the document you've just rendered with TT, and the
> other attachments and doing the right thing.
>
> Cheers
> t0m
>
>
>
> ______________________________**_________________
> List: Catalyst at lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-**bin/mailman/listinfo/catalyst<ht=
tp://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst>
> Searchable archive: http://www.mail-archive.com/**
> catalyst at lists.scsys.co.uk/<http://www.mail-archive.com/catalyst@lists.sc=
sys.co.uk/>
> Dev site: http://dev.catalyst.perl.org/
>



-- =

"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/20111223/ba3e9=
e9a/attachment.htm


More information about the Catalyst mailing list