]> iEval git - app-web-oof.git/commitdiff
Send email when an order is placed
authorMarius Gavrilescu <marius@ieval.ro>
Sat, 7 May 2016 17:44:29 +0000 (18:44 +0100)
committerMarius Gavrilescu <marius@ieval.ro>
Sat, 7 May 2016 17:44:29 +0000 (18:44 +0100)
Makefile.PL
README
lib/App/Web/Oof.pm

index ffc13b0ffdba076b2c3db34124d006363abeb173..fb896ce28baa724a02ac9e747d7f688cd20bc581 100644 (file)
@@ -13,6 +13,8 @@ WriteMakefile(
                qw/Plack::App::File       0
                   Plack::Builder         0
                   DBIx::Simple           0
+                  Email::Sender::Simple  0
+                  Email::Simple          0
                   File::Slurp            0
                   HTML::TreeBuilder      0
                   HTML::Element::Library 0
diff --git a/README b/README
index db4dc6247bff452b6f5ef0d5d894e338bd992276..b316bf114572655189977a0eba34abc00d815c55 100644 (file)
--- a/README
+++ b/README
@@ -23,9 +23,13 @@ This module requires these other modules and libraries:
 
 * Plack
 * DBIx::Simple
+* Email::Simple
+* Email::Sender::Simple
+* File::Slurp
 * HTML::Element
 * HTML::Element::Library
 * JSON::MaybeXS
+* Try::Tiny
 
 COPYRIGHT AND LICENCE
 
index fa256a6965411da2ec9fca71097846d51960f8c0..405ffb52a1cae80c430216fdb7c2bb73f35d1868 100644 (file)
@@ -9,6 +9,8 @@ use parent qw/Plack::Component/;
 our $VERSION = '0.000_005';
 
 use DBIx::Simple;
+use Email::Sender::Simple 'sendmail';
+use Email::Simple;
 use File::Slurp;
 use HTML::TreeBuilder;
 use HTML::Element::Library;
@@ -208,6 +210,14 @@ sub order_app {
                        }
                        $db{$$}->insert(orders => {id => $id, %parms});
                        $db{$$}->commit;
+                       sendmail (Email::Simple->create(
+                               header => [
+                                       From    => $ENV{OOF_EMAIL_FROM},
+                                       To      => $ENV{OOF_EMAIL_TO},
+                                       Subject => "Order $id placed",
+                               ],
+                               body => 'A new order was placed.',
+                       )) if $ENV{OOF_EMAIL_TO};
                } catch {
                        $db{$$}->rollback;
                        $err = [500, ['Content-type', 'text/plain'], ["Error: $_"]]
This page took 0.025234 seconds and 4 git commands to generate.