Send email when an order is placed
[app-web-oof.git] / lib / App / Web / Oof.pm
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.010355 seconds and 4 git commands to generate.