Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- myApp.controllers
- //===============================================
- //= forget password page controller
- //===============================================
- .controller('ForgetPasswordCtrl',['$scope','$stateParams','$http','$ionicPopup','AppData','$state','$rootScope',
- function($scope, $stateParams,$http,$ionicPopup,AppData,$state,$rootScope) {
- if( window.localStorage.getItem('loggedIn') === "true"){
- $state.go('home');
- }
- $scope.forgotPassword = {};
- //----registeration function executes on register button click-----
- $scope.submit = function(forgotPassword){
- var emailReg = /^([w-]+(?:.[w-]+)*)@((?:[w-]+.)*w[w-]{0,66}).([a-z]{2,6}(?:.[a-z]{2})?)$/i;
- if(!forgotPassword.email){
- $ionicPopup.alert({content: 'Ungültige E-Mail!'});
- }else if(!emailReg.test(forgotPassword.email)){
- $ionicPopup.alert({content: 'Ungültige E-Mail!'});
- }else{
- $rootScope.showLoader = true;
- $http.post(AppData.get("siteUrl") + "forgot-password.php", forgotPassword).then(function (res){
- $rootScope.showLoader = false;
- $scope.response = res.data;
- if($scope.response.result == 0){
- $ionicPopup.alert({
- content: 'Fehler'
- });
- }else if($scope.response.result == 1){
- $ionicPopup.alert({
- content: 'Wir haben Ihnen eine E-Mail gesandt.'
- });
- }
- });
- }
- }
- }]);
- <?php
- require 'mailer/PHPMailerAutoload.php';
- if (isset($_SERVER['HTTP_ORIGIN'])) {
- header("Access-Control-Allow-Origin: {$_SERVER['HTTP_ORIGIN']}");
- header('Access-Control-Allow-Credentials: true');
- header('Access-Control-Max-Age: 86400'); // cache for 1 day
- }
- // Access-Control headers are received during OPTIONS requests
- if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS') {
- if (isset($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_METHOD']))
- header("Access-Control-Allow-Methods: GET, POST, OPTIONS");
- if (isset($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS']))
- header("Access-Control-Allow-Headers: {$_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS']}");
- exit(0);
- }
- $postdata = file_get_contents("php://input");
- if (isset($postdata)) {
- $request = json_decode($postdata);
- forgot($request);
- }
- function forgot($request){
- $email = $request->email;
- $mail = new PHPMailer;
- // $mail->SMTPDebug = 3; // Enable verbose debug output
- $mail->isSMTP(); // Set mailer to use SMTP
- $mail->Host = '*****'; // Specify main and backup SMTP servers
- $mail->SMTPAuth = true; // Enable SMTP authentication
- $mail->Username = 'noreply@*****'; // SMTP username
- $mail->Password = '*****'; // SMTP password
- $mail->SMTPSecure = 'ssl'; // Enable TLS encryption, `ssl` also accepted
- $mail->Port = 465; // TCP port to connect to
- $mail->setFrom('noreply@v*****', 'myApp');
- $mail->addAddress($email, 'Joe User');
- $mail->isHTML(true); // Set email format to HTML
- $mail->Subject = 'this is the test mail';
- $mail->Body = 'This is the HTML message body <b>in bold!</b>';
- $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
- if($mail->send()){
- echo '{"result":1}';
- }else{
- echo '{"result":2}';
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement