This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
define('DATABASE_HOST', "localhost"); | |
define('DATABASE_NAME', "demos"); | |
define('DATABASE_USERNAME', "root"); | |
define('DATABASE_PASSWORD', "root"); | |
define('ATTACHED_FILENAME', "books.pdf"); | |
define('SENDGRID_USERNAME', "YOUR_SENDGRID_USERNAME"); | |
define('SENDGRID_PASSWORD', "YOUR_SENDGRID_PASSWORD"); | |
define('FROM', "demo@angularcode.com"); | |
define('TO', "support@codenx.com"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- | |
-- Table structure for table `books` | |
-- | |
CREATE TABLE IF NOT EXISTS `books` ( | |
`name` varchar(255) DEFAULT NULL, | |
`author` varchar(255) DEFAULT NULL | |
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8; | |
-- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Database { | |
private $host = "localhost"; | |
private $user = "root"; | |
private $password = "root"; | |
private $database = "crud"; | |
function runQuery($sql) { | |
$conn = new mysqli($this->host,$this->user,$this->password,$this->database); | |
if ($conn->connect_error) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
include('database.php'); | |
$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`='crud' | |
AND `TABLE_NAME`='books' | |
and `COLUMN_NAME` in ('name','author')"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var express = require('express'); | |
var bodyParser = require('body-parser'); | |
var nodemailer = require('nodemailer'); | |
var sgTransport = require('nodemailer-sendgrid-transport'); | |
var app = express(); | |
app.use(express.static(__dirname + '/client')); | |
app.use(bodyParser.json()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "sendmail", | |
"version": "1.0.0", | |
"dependencies": { | |
"body-parser": "^1.14.2", | |
"express": "^4.13.4", | |
"nodemailer": "^2.1.0", | |
"nodemailer-sendgrid-transport": "^0.2.0" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
angular.module('sendmailApp', []) | |
.controller('MailController', function ($scope,$http) { | |
$scope.loading = false; | |
$scope.send = function (mail){ | |
$scope.loading = true; | |
$http.post('/sendmail', { | |
from: 'CodeNx <admin@angularcode.com>', | |
to: 'support@codenx.com', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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="css/materialize.css" type="text/css" rel="stylesheet" media="screen,projection"/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var express = require('express'); | |
var app = express(); | |
var path = require('path'); | |
var http = require('http'); | |
var multer = require('multer'); | |
var storage = multer.diskStorage({ | |
destination: './uploads/', | |
filename: function (req, file, cb) { | |
cb(null, file.originalname.replace(path.extname(file.originalname), "") + '-' + Date.now() + path.extname(file.originalname)) |