Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2019
986
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.92 KB | None | 0 0
  1. class Mail
  2. {
  3. public function sendMail($to, $subject, $text, $html)
  4. {
  5. $mail = new PHPMailer(true);
  6.  
  7. try {
  8. //Server settings
  9. $mail->SMTPDebug = 3;
  10. $mail->isSMTP();
  11. $mail->Host = 'smtp.gmail.com';
  12. $mail->SMTPAuth = true;
  13. $mail->Username = 'wuwu5431@gmail.com';
  14. $mail->Password = 'Password';
  15. $mail->SMTPSecure = 'tls';
  16. $mail->Port = 587;
  17.  
  18. //Recipients
  19. $mail->setFrom('wuwu5431@gmail.com', 'John Smith');
  20. $mail->addAddress($to, '');
  21. $mail->addReplyTo('wuwu5431@gmail.com', 'Information($mail->addReplyTo)');
  22.  
  23. //Content
  24. $mail->isHTML(true);
  25. $mail->Subject = $subject;
  26. $mail->Body = $text;
  27. $mail->AltBody = $html . ' $html . This is the body in plain text for non-HTML mail clients';
  28.  
  29. $mail->send();
  30.  
  31. echo 'Message has been sent';
  32. } catch (Exception $e) {
  33. echo 'Message could not be sent. Mailer Error: ', $mail->ErrorInfo;
  34. }
  35.  
  36. }//end of method
  37. }// end of class
  38.  
  39. public function sendActivationEmail($email)
  40. {
  41. $url = 'url';
  42. $text = 'text';
  43. $html = 'html';
  44. $mail = new AppMail;
  45. $mail->sendMail($email, 'Account activation', $text, $html);
  46. }
  47.  
  48. public function register()
  49. {
  50. if ($_SERVER['REQUEST_METHOD'] == 'POST'){
  51. $_POST = filter_input_array(INPUT_POST, FILTER_SANITIZE_STRING);
  52. foreach($_POST as $key => $value){
  53. $data[$key] = htmlspecialchars(strip_tags(trim($value)));
  54. }
  55. $this->userModel = new AppModelsUserM;
  56. if ($this->userModel->Register($data)) {
  57. Flash::addMessage('Thank you for Registering with us');
  58. $this->userModel->sendActivationEmail($data['email']);
  59. $this->redirect('User/UserC/success');
  60. }
  61. }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement