Advertisement
Guest User

Untitled

a guest
Jan 15th, 2017
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.49 KB | None | 0 0
  1. myApp.controllers
  2. //===============================================
  3. //= forget password page controller
  4. //===============================================
  5. .controller('ForgetPasswordCtrl',['$scope','$stateParams','$http','$ionicPopup','AppData','$state','$rootScope',
  6. function($scope, $stateParams,$http,$ionicPopup,AppData,$state,$rootScope) {
  7. if( window.localStorage.getItem('loggedIn') === "true"){
  8. $state.go('home');
  9. }
  10. $scope.forgotPassword = {};
  11. //----registeration function executes on register button click-----
  12. $scope.submit = function(forgotPassword){
  13. var emailReg = /^([w-]+(?:.[w-]+)*)@((?:[w-]+.)*w[w-]{0,66}).([a-z]{2,6}(?:.[a-z]{2})?)$/i;
  14. if(!forgotPassword.email){
  15. $ionicPopup.alert({content: 'Ungültige E-Mail!'});
  16. }else if(!emailReg.test(forgotPassword.email)){
  17. $ionicPopup.alert({content: 'Ungültige E-Mail!'});
  18. }else{
  19. $rootScope.showLoader = true;
  20. $http.post(AppData.get("siteUrl") + "forgot-password.php", forgotPassword).then(function (res){
  21. $rootScope.showLoader = false;
  22. $scope.response = res.data;
  23. if($scope.response.result == 0){
  24. $ionicPopup.alert({
  25. content: 'Fehler'
  26. });
  27. }else if($scope.response.result == 1){
  28. $ionicPopup.alert({
  29. content: 'Wir haben Ihnen eine E-Mail gesandt.'
  30. });
  31. }
  32. });
  33. }
  34. }
  35. }]);
  36.  
  37. <?php
  38.  
  39. require 'mailer/PHPMailerAutoload.php';
  40.  
  41. if (isset($_SERVER['HTTP_ORIGIN'])) {
  42. header("Access-Control-Allow-Origin: {$_SERVER['HTTP_ORIGIN']}");
  43. header('Access-Control-Allow-Credentials: true');
  44. header('Access-Control-Max-Age: 86400'); // cache for 1 day
  45. }
  46.  
  47. // Access-Control headers are received during OPTIONS requests
  48. if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS') {
  49.  
  50. if (isset($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_METHOD']))
  51. header("Access-Control-Allow-Methods: GET, POST, OPTIONS");
  52.  
  53. if (isset($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS']))
  54. header("Access-Control-Allow-Headers: {$_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS']}");
  55.  
  56. exit(0);
  57. }
  58. $postdata = file_get_contents("php://input");
  59. if (isset($postdata)) {
  60. $request = json_decode($postdata);
  61. forgot($request);
  62. }
  63.  
  64.  
  65. function forgot($request){
  66.  
  67. $email = $request->email;
  68. $mail = new PHPMailer;
  69. // $mail->SMTPDebug = 3; // Enable verbose debug output
  70.  
  71. $mail->isSMTP(); // Set mailer to use SMTP
  72. $mail->Host = '*****'; // Specify main and backup SMTP servers
  73. $mail->SMTPAuth = true; // Enable SMTP authentication
  74. $mail->Username = 'noreply@*****'; // SMTP username
  75. $mail->Password = '*****'; // SMTP password
  76. $mail->SMTPSecure = 'ssl'; // Enable TLS encryption, `ssl` also accepted
  77. $mail->Port = 465; // TCP port to connect to
  78.  
  79. $mail->setFrom('noreply@v*****', 'myApp');
  80. $mail->addAddress($email, 'Joe User');
  81.  
  82. $mail->isHTML(true); // Set email format to HTML
  83.  
  84. $mail->Subject = 'this is the test mail';
  85. $mail->Body = 'This is the HTML message body <b>in bold!</b>';
  86. $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
  87. if($mail->send()){
  88. echo '{"result":1}';
  89. }else{
  90. echo '{"result":2}';
  91. }
  92. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement