big addition, have fun
Sebastian Riedel [Wed, 6 Apr 2005 22:57:08 +0000 (22:57 +0000)]
Changes [new file with mode: 0644]
Email.pm [new file with mode: 0644]
MANIFEST [new file with mode: 0644]
Makefile.PL [new file with mode: 0644]
README [new file with mode: 0644]
test.pl [new file with mode: 0644]

diff --git a/Changes b/Changes
new file mode 100644 (file)
index 0000000..b93b6ad
--- /dev/null
+++ b/Changes
@@ -0,0 +1,10 @@
+Revision history for Perl extension Catalyst::Plugin::Email.
+
+0.03  Wed Feb 02 18:00:00 2005
+        - bugfix
+
+0.02  Sun Jan 30 18:00:00 2005
+        - new api
+
+0.01  Fri Jan 28 22:00:00 2005
+        - first release
diff --git a/Email.pm b/Email.pm
new file mode 100644 (file)
index 0000000..8410338
--- /dev/null
+++ b/Email.pm
@@ -0,0 +1,68 @@
+package Catalyst::Plugin::Email;
+
+use strict;
+use Email::Send;
+use Email::MIME;
+use Email::MIME::Creator;
+
+our $VERSION = '0.03';
+
+=head1 NAME
+
+Catalyst::Plugin::Email - Send emails with Catalyst
+
+=head1 SYNOPSIS
+
+    use Catalyst 'Email';
+
+    __PACKAGE__->config->{email} = [qw/SMTP smtp.oook.de/];
+
+    $c->email(
+        header => [
+            From    => 'sri@oook.de',
+            To      => 'sri@cpan.org',
+            Subject => 'Hello!'
+        ],
+        body => 'Hello sri'
+    );
+
+=head1 DESCRIPTION
+
+Send emails with Catalyst and L<Email::Send> and L<Email::MIME::Creator>.
+
+=head2 METHODS
+
+=head3 email
+
+=cut
+
+sub email {
+    my $c = shift;
+    my $email = $_[1] ? {@_} : $_[0];
+    $email = Email::MIME->create(%$email);
+    my $args = $c->config->{email} || [];
+    my @args = @{$args};
+    my $class;
+    unless ( $class = shift @args ) {
+        $class = 'SMTP';
+        unshift @args, 'localhost';
+    }
+    send $class => $email, @args;
+}
+
+=head1 SEE ALSO
+
+L<Catalyst>.
+
+=head1 AUTHOR
+
+Sebastian Riedel, C<sri@cpan.org>
+
+=head1 COPYRIGHT
+
+This program is free software, you can redistribute it and/or modify it under
+the same terms as Perl itself.
+
+=cut
+
+1;
diff --git a/MANIFEST b/MANIFEST
new file mode 100644 (file)
index 0000000..24108e9
--- /dev/null
+++ b/MANIFEST
@@ -0,0 +1,7 @@
+Changes
+Email.pm
+Makefile.PL
+MANIFEST                       This list of files
+README
+test.pl
+META.yml                                 Module meta-data (added by MakeMaker)
diff --git a/Makefile.PL b/Makefile.PL
new file mode 100644 (file)
index 0000000..2272adc
--- /dev/null
@@ -0,0 +1,13 @@
+use ExtUtils::MakeMaker;
+
+WriteMakefile(
+    NAME      => 'Catalyst::Plugin::Email',
+    AUTHOR    => 'Sebastian Riedel (sri@oook.de)',
+    PREREQ_PM => {
+        Catalyst             => '2.99',
+        Email::Send          => 0,
+        Email::MIME          => 0,
+        Email::MIME::Creator => 0
+    },
+    VERSION_FROM => 'Email.pm'
+);
diff --git a/README b/README
new file mode 100644 (file)
index 0000000..93c1004
--- /dev/null
+++ b/README
@@ -0,0 +1,32 @@
+NAME
+    Catalyst::Plugin::Email - Send emails with Catalyst
+
+SYNOPSIS
+        use Catalyst 'Email';
+
+        __PACKAGE__->config->{email} = qw/SMTP smtp.oook.de/;
+
+        $c->email(
+            header => [
+                From    => 'sri@oook.de',
+                To      => 'sri@cpan.org',
+                Subject => 'Hello!'
+            ],
+            body => 'Hello sri'
+        );
+
+DESCRIPTION
+    Send emails with Catalyst and Email::Send and Email::MIME::Creator.
+
+  METHODS
+   email
+SEE ALSO
+    Catalyst.
+
+AUTHOR
+    Sebastian Riedel, "sri@cpan.org"
+
+COPYRIGHT
+    This program is free software, you can redistribute it and/or modify it
+    under the same terms as Perl itself.
+
diff --git a/test.pl b/test.pl
new file mode 100644 (file)
index 0000000..d8c9e7d
--- /dev/null
+++ b/test.pl
@@ -0,0 +1,4 @@
+use strict;
+use Test::More tests => 1;
+
+BEGIN { use_ok('Catalyst::Plugin::Email') }