Permalink
Browse files

Integrated angularjs

  • Loading branch information...
1 parent 982cb79 commit d1bc934ba9dfee6fb9fad5f4a789e580d87b8767 @itswadesh committed Mar 29, 2016
View
No changes.
View
@@ -8,7 +8,7 @@ This will create necessary tables and insert sample data into it.
The following settings need to be changed at **config.php**
<pre>
define('DATABASE_HOST', "localhost");
- define('DATABASE_NAME', "demo");
+ define('DATABASE_NAME', "demos");
define('DATABASE_USERNAME', "root");
define('DATABASE_PASSWORD', "root");
@@ -17,16 +17,11 @@ The following settings need to be changed at **config.php**
define('SENDGRID_USERNAME', "YOUR_SENDGRID_USERNAME");
define('SENDGRID_PASSWORD', "YOUR_SENDGRID_PASSWORD");
- define('FROM', "<AngularCode> demo@angularcode.com");
+ define('FROM', "demo@angularcode.com");
define('TO', "support@codenx.com");
define('SUBJECT', "ShopNx - The Single Page eCommerce Website");
- define('CONTENT', "
- <h1>Experience faster shopping with ShopNx</h1>
- <ul>
- <li>Responsive Design</li>
- <li>Higher Scalability</li>
- <li>Ergonomically Designed</li>
- </ul>");
+ define('CONTENT', "<h1>Experience faster shopping with ShopNx</h1>
+ <ul> <li>Responsive Design</li><li>Higher Scalability</li><li>Ergonomically Designed</li></ul>");
</pre>
View
Binary file not shown.
@@ -1,6 +1,6 @@
<?php
define('DATABASE_HOST', "localhost");
- define('DATABASE_NAME', "demo");
+ define('DATABASE_NAME', "demos");
define('DATABASE_USERNAME', "root");
define('DATABASE_PASSWORD', "root");
@@ -9,7 +9,7 @@
define('SENDGRID_USERNAME', "YOUR_SENDGRID_USERNAME");
define('SENDGRID_PASSWORD', "YOUR_SENDGRID_PASSWORD");
- define('FROM', "<AngularCode> demo@angularcode.com");
+ define('FROM', "demo@angularcode.com");
define('TO', "support@codenx.com");
define('SUBJECT', "ShopNx - The Single Page eCommerce Website");
define('CONTENT', "
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -1,11 +1,14 @@
<?php
include('config.php');
include('database.php');
+$email = TO;
+if(isset($_POST['email'])) $email = $_POST['email'];
+
$database = new Database();
$result = $database->runQuery("SELECT name,author FROM books");
$header = $database->runQuery("SELECT UCASE(`COLUMN_NAME`)
FROM `INFORMATION_SCHEMA`.`COLUMNS`
-WHERE `TABLE_SCHEMA`='demo'
+WHERE `TABLE_SCHEMA`='demos'
AND `TABLE_NAME`='books'
and `COLUMN_NAME` in ('name','author')");
@@ -25,5 +28,6 @@
}
$pdf->Output(ATTACHED_FILENAME,'F');
require('sendgrid.php');
-sendmail();
+$result = sendmail($email);
+echo $result;
?>
View
@@ -0,0 +1,41 @@
+<?php
+include('config.php');
+function sendmail($email){
+ $url = 'https://api.sendgrid.com/';
+ $filePath = dirname(__FILE__);
+
+ $params = array(
+ 'api_user' => SENDGRID_USERNAME,
+ 'api_key' => SENDGRID_PASSWORD,
+ 'from' => FROM,
+ 'to' => $email,
+ 'subject' => SUBJECT,
+ 'html' => CONTENT,
+ 'files['.ATTACHED_FILENAME.']' => '@'.$filePath.'/'.ATTACHED_FILENAME
+ );
+
+ $request = $url.'api/mail.send.json';
+
+ // Generate curl request
+ $session = curl_init($request);
+
+ // Tell curl to use HTTP POST
+ curl_setopt ($session, CURLOPT_POST, true);
+
+ // Tell curl that this is the body of the POST
+ curl_setopt ($session, CURLOPT_POSTFIELDS, $params);
+
+ // Tell curl not to return headers, but do return the response
+ curl_setopt($session, CURLOPT_HEADER, false);
+ // Tell PHP not to use SSLv3 (instead opting for TLS)
+ curl_setopt($session, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1_2);
+ curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
+
+ // obtain response
+ $response = curl_exec($session);
+ curl_close($session);
+
+ // return the executation state
+ return $response;
+}
+?>
View
@@ -0,0 +1,17 @@
+'use strict';
+
+angular.module('sendmailApp', [])
+.controller('MailController', function ($scope,$http) {
+ $scope.loading = false;
+ $scope.mail = {to: 'support@codenx.com'};
+ $scope.send = function (mail){
+ $scope.loading = true;
+ $http.post('api/index.php', { to: mail.to }).then(res=>{
+ $scope.loading = false;
+ if(res.status===200)
+ $scope.serverMessage = 'Email sent with attachment';
+ else
+ $scope.serverMessage = 'Error sending email';
+ });
+ }
+})
View
@@ -0,0 +1,22 @@
+[ng\:cloak], [ng-cloak], [data-ng-cloak], [x-ng-cloak], .ng-cloak, .x-ng-cloak {
+ display: none !important;
+}
+.icon-block {
+ padding: 0 15px;
+}
+.icon-block .material-icons {
+ font-size: inherit;
+}
+.success{
+ color: limegreen;
+ font-size: 20px;
+}
+body {
+ display: flex;
+ min-height: 100vh;
+ flex-direction: column;
+}
+
+main {
+ flex: 1 0 auto;
+}
View
@@ -0,0 +1,72 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
+ <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0"/>
+ <title>Send email using NodeJS</title>
+
+ <!-- CSS -->
+ <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
+ <link href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.5/css/materialize.min.css" type="text/css" rel="stylesheet" media="screen,projection"/>
+ <link href="css/style.css" type="text/css" rel="stylesheet" media="screen,projection"/>
+</head>
+<body ng-app="sendmailApp" ng-controller="MailController">
+ <header>
+ <nav class="light-blue lighten-1" role="navigation">
+ <div class="nav-wrapper container"><a id="logo-container" href="http://www.angularcode.com/" class="brand-logo">AngularCode | Demo</a>
+ <ul class="right">
+ <li><a class="dropdown-button" href="http://www.angularcode.com/send-email-from-website-using-angularjs-and-nodejs"
+ data-activates="dropdown1">Tutorial<i class="material-icons left">airplay</i></a></li>
+
+ </ul>
+ </div>
+ </nav>
+ </header>
+ <main>
+ <div class="section no-pad-bot valign-wrapper">
+ <div class="container">
+ <br><br>
+ <div class="center"><i class="material-icons center large">attachment</i>
+ <h1 class="header green-text">Send me the file as attachment</h1>
+ </div>
+ <div class="center success">
+ <div class="preloader-wrapper small active" ng-if="loading">
+ <div class="spinner-layer spinner-green-only">
+ <div class="circle-clipper left">
+ <div class="circle"></div>
+ </div><div class="gap-patch">
+ <div class="circle"></div>
+ </div><div class="circle-clipper right">
+ <div class="circle"></div>
+ </div>
+ </div>
+ </div>
+ <div ng-cloak ng-if="!loading && serverMessage"><i class="material-icons center">done</i>{{serverMessage}}</div>
+ </div>
+ <div class="row center">
+ <div class="input-field col s12 z-depth-2">
+ <input ng-model="mail.to" class="materialize-text" placeholder="support@codenx.com"></input>
+ </div>
+ </div>
+ <div class="row center">
+ <button ng-click="send(mail)" class="btn-large waves-effect waves-light green" ng-disabled="loading"><i class="material-icons left">send</i>
+ <div class="circle"></div>Send Mail</button>
+ </div>
+ <br><br>
+
+ </div>
+ </div>
+ </main>
+ <footer class="page-footer orange">
+ <div class="footer-copyright">
+ <div class="container center">
+ Crafted by <a class="orange-text text-lighten-3" href="http://angularcode.com">AngularCode</a>
+ </div>
+ </div>
+ </footer>
+
+ <!-- Scripts-->
+ <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.2/angular.min.js"></script>
+ <script type="text/javascript" src="app.js"></script>
+ </body>
+</html>
View
@@ -1,43 +0,0 @@
-<?php
-include('config.php');
-function sendmail(){
-$url = 'https://api.sendgrid.com/';
-$filePath = dirname(__FILE__);
-
-$params = array(
- 'api_user' => SENDGRID_USERNAME,
- 'api_key' => SENDGRID_PASSWORD,
- 'from' => FROM,
- 'to' => TO,
- 'subject' => SUBJECT,
- 'html' => CONTENT,
- 'files['.ATTACHED_FILENAME.']' => '@'.$filePath.'/'.ATTACHED_FILENAME
- );
-
-print_r($params.message);
-
-$request = $url.'api/mail.send.json';
-
-// Generate curl request
-$session = curl_init($request);
-
-// Tell curl to use HTTP POST
-curl_setopt ($session, CURLOPT_POST, true);
-
-// Tell curl that this is the body of the POST
-curl_setopt ($session, CURLOPT_POSTFIELDS, $params);
-
-// Tell curl not to return headers, but do return the response
-curl_setopt($session, CURLOPT_HEADER, false);
-// Tell PHP not to use SSLv3 (instead opting for TLS)
-curl_setopt($session, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1_2);
-curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
-
-// obtain response
-$response = curl_exec($session);
-curl_close($session);
-
-// print everything out
-print_r($response);
-}
-?>

0 comments on commit d1bc934

Please sign in to comment.