Advertisement
Adeeb_Haddad

Untitled

Dec 11th, 2019
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.79 KB | None | 0 0
  1. func callMailAPI()
  2. {
  3. let strEmail = defaults.value(forKey: "recoveryEmail") as! String
  4. let strPass = defaults.value(forKey: "Passcode") as! String
  5.  
  6. let strSubject = NSLocalizedString("Your passcode recovery from Photolock", comment: "Your passcode recovery from Photolock")
  7.  
  8. //let strBody = NSLocalizedString("Hello", comment: "Hello") + " \n\n" + NSLocalizedString("You requested a passcode recovery, here is your passcode:", comment: "You requested a passcode recovery, here is your passcode:") + " " + strPass + " \n\n" + NSLocalizedString("Thank you for using photo lock!", comment: "Thank you for using photo lock!") + " \n"
  9.  
  10. var strUrl :String = ""
  11. strUrl = "http://apphousecompany.com/api/send_mail.php"
  12.  
  13. let Url = URL.init(string: strUrl)
  14. print(strUrl)
  15.  
  16. let params = ["to_email":strEmail, "message":strPass , "subject":strSubject , "hello": NSLocalizedString("Hello", comment: "Hello") , "msg": NSLocalizedString("You requested a passcode recovery, here is your passcode:", comment: "You requested a passcode recovery, here is your passcode:") + " " + strPass , "thanks" : NSLocalizedString("Thank you for using photo lock!", comment: "Thank you for using photo lock!")]
  17.  
  18. Alamofire.request(Url!, method: .post, parameters: params, encoding: URLEncoding.default, headers: nil).response {response in
  19.  
  20. let returnData = String(data: response.data!, encoding: .utf8)
  21. print(returnData!)
  22. if returnData! == "Passcode sent successfully"
  23. {
  24. self.mailSentAlert()
  25. }
  26. else
  27. {
  28. self.showAlertWarning(msg: "Error sending recovery email. Please try again.")
  29. }
  30. }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement