aboutsummaryrefslogtreecommitdiffstats
path: root/lib/MGA/Mirrors/View
diff options
context:
space:
mode:
authorOlivier Thauvin <nanardon@mageia.org>2010-10-19 22:50:58 +0000
committerOlivier Thauvin <nanardon@mageia.org>2010-10-19 22:50:58 +0000
commit5972196ee5ac7deb2291814bd1c278ce69e4b32a (patch)
tree0e48bb471d3b7ee99b21e6ad823f8dc347b2a9e8 /lib/MGA/Mirrors/View
parent9fa18a22880f52192667c9df42d37bd75d11f1f4 (diff)
downloadmgamirrors-5972196ee5ac7deb2291814bd1c278ce69e4b32a.tar
mgamirrors-5972196ee5ac7deb2291814bd1c278ce69e4b32a.tar.gz
mgamirrors-5972196ee5ac7deb2291814bd1c278ce69e4b32a.tar.bz2
mgamirrors-5972196ee5ac7deb2291814bd1c278ce69e4b32a.tar.xz
mgamirrors-5972196ee5ac7deb2291814bd1c278ce69e4b32a.zip
- ask confirm by mail on host information update to avoid spam
Diffstat (limited to 'lib/MGA/Mirrors/View')
-rw-r--r--lib/MGA/Mirrors/View/Mail.pm59
1 files changed, 59 insertions, 0 deletions
diff --git a/lib/MGA/Mirrors/View/Mail.pm b/lib/MGA/Mirrors/View/Mail.pm
new file mode 100644
index 0000000..0c694be
--- /dev/null
+++ b/lib/MGA/Mirrors/View/Mail.pm
@@ -0,0 +1,59 @@
+package MGA::Mirrors::View::Mail;
+
+use strict;
+use base 'Catalyst::View::TT';
+use Mail::Mailer;
+use MGA::Mirrors;
+
+__PACKAGE__->config(
+ TEMPLATE_EXTENSION => '.tt',
+ INCLUDE_PATH => MGA::Mirrors->path_to( 'root', 'mail' ),
+);
+
+=head1 NAME
+
+MGA::Mirrors::View::TT - TT View for MGA::Mirrors
+
+=head1 DESCRIPTION
+
+TT View for MGA::Mirrors.
+
+=cut
+
+sub render {
+ my ($self, $c, $template, $args) = @_;
+
+ $ENV{MAILADDRESS} = $args->{From};
+ my $mailer = new Mail::Mailer 'smtp', Server => (MGA::Mirrors->config->{smtp} || 'localhost');
+ eval {
+ $mailer->open({
+ (map { $_ => $args->{$_} } grep { $_ !~ /^(mail)$/ } keys %{ $args || {}}),
+ 'Content-Type' => 'text/plain; charset=UTF-8; format=flowed',
+ 'Content-Transfer-Encoding' => '8bit',
+ 'X-MGA-Mirrors-version' => $MGA::Mirrors::DB::VERSION,
+ });
+ print $mailer
+ Catalyst::View::TT::render($self, $c, $template, { %{ $args->{mail} || {} }, c => $c });
+ $mailer->close;
+ };
+ if ($@) {
+ $c->stash->{mail_error} = $@;
+ }
+}
+
+=head1 SEE ALSO
+
+L<MGA::Mirrors>
+
+=head1 AUTHOR
+
+Thauvin Olivier
+
+=head1 LICENSE
+
+This library is free software, you can redistribute it and/or modify
+it under the same terms as Perl itself or CeCILL.
+
+=cut
+
+1;