source: trunk/lib/Vote/View/Mail.pm @ 194

Last change on this file since 194 was 194, checked in by nanardon, 15 years ago
  • clearly separate Catalyst Model and Vote::DB module, making test faster
File size: 1.1 KB
Line 
1package Vote::View::Mail;
2
3use strict;
4use base 'Catalyst::View::TT';
5use Mail::Mailer;
6use Vote::DB;
7
8__PACKAGE__->config(
9    TEMPLATE_EXTENSION => '.tt',
10    INCLUDE_PATH => Vote->path_to( 'root', 'mail' ),
11    PLUGIN_BASE => 'Vote::Template::Plugin',
12);
13
14=head1 NAME
15
16Vote::View::TT - TT View for Vote
17
18=head1 DESCRIPTION
19
20TT View for Vote.
21
22=cut
23
24sub render {
25    my ($self, $c, $template, $args) = @_;
26
27    $ENV{MAILADDRESS} = $args->{From};
28    my $mailer = new Mail::Mailer 'smtp', Server => (Vote->config->{smtp} || 'localhost');
29    $mailer->open({
30        (map { $_ => $args->{$_} } grep { $_ !~ /^(mail)$/ } keys %{ $args || {}}),
31        'Content-Type' => 'text/plain; charset=UTF-8; format=flowed',
32        'Content-Transfer-Encoding' => '8bit',
33        'X-Epoll-version' => $Vote::DB::VERSION,
34    });
35    print $mailer
36    Catalyst::View::TT::render($self, $c, $template, { %{ $args->{mail} || {} }, c => $c });
37    $mailer->close;
38}
39
40=head1 SEE ALSO
41
42L<Vote>
43
44=head1 AUTHOR
45
46Thauvin Olivier
47
48=head1 LICENSE
49
50This library is free software, you can redistribute it and/or modify
51it under the same terms as Perl itself or CeCILL.
52
53=cut
54
551;
Note: See TracBrowser for help on using the repository browser.