Advertisement
Guest User

Untitled

a guest
Jan 27th, 2017
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.48 KB | None | 0 0
  1. public function sendEnrollment(){
  2.  
  3. try {
  4. $name = $this->input->post('name');
  5. $email = $this->input->post('mail');
  6. $institution = $this->input->post('institution');
  7. $coupon = $this->input->post('coupon');
  8. $course = $this->input->post('course');
  9.  
  10. $mail = new PHPMailer();
  11.  
  12. $body = file_get_contents('assets/template/send_enrollment.html');
  13. $body = preg_replace("{#name#}", $name, $body);
  14. $body = preg_replace("{#email#}", $email, $body);
  15. $body = preg_replace("{#cpf#}", $cpf, $body);
  16. $body = preg_replace("{#coupon#}", $coupon, $body);
  17. $body = preg_replace("{#course#}", $course, $body);
  18. $body = preg_replace("{#institution#}", $institution, $body);
  19.  
  20. $mail->IsSMTP();
  21. $mail->SMTPAuth = true;
  22. $mail->SMTPSecure = "ssl";
  23. $mail->Host = "br276.hostgator.com.br";
  24. $mail->Port = 465;
  25.  
  26. $mail->Username = "mkt@escolacontrata.com.br";
  27. $mail->Password = "marketing1";
  28.  
  29. $mail->From = "mkt@escolacontrata.com.br";
  30. $mail->FromName = "Escola Contrata";
  31. $mail->Subject = 'Cupom de Desconto:' . $course;
  32. $mail->WordWrap = 50;
  33. $mail->MsgHTML($body);
  34. $mail->AddAddress($email, $name);
  35. $mail->CharSet = "UTF-8";
  36. $mail->IsHTML(true);
  37.  
  38. if($mail->Send()) {
  39. $error = true;
  40. } else {
  41. $error = $mail->ErrorInfo;
  42. }
  43. } catch(Exception $e){
  44. $error = $e->getMessage();
  45. } finally {
  46. echo json_encode(array('error' => $error));
  47. }
  48.  
  49. self::sendEnrollmentRedirect();
  50. }
  51.  
  52.  
  53. private function sendEnrollmentRedirect($param){
  54. try {
  55. $name = $this->input->post('name');
  56. $email = $this->input->post('mail');
  57. $cpf = $this->input->post('cpf');
  58. $institution = $this->input->post('institution');
  59. $institutionMail = $this->input->post('institutionMail');
  60. $coupon = $this->input->post('coupon');
  61. $course = $this->input->post('course');
  62. $state = $this->input->post('state');
  63. $city = $this->input->post('city');
  64.  
  65. $mail = new PHPMailer();
  66.  
  67. $body = file_get_contents('assets/template/send_enrollment_redirect.html');
  68. $body = preg_replace("{#name#}", $name, $body);
  69. $body = preg_replace("{#email#}", $email, $body);
  70. $body = preg_replace("{#cpf#}", $cpf, $body);
  71. $body = preg_replace("{#coupon#}", $coupon, $body);
  72. $body = preg_replace("{#course#}", $course, $body);
  73. $body = preg_replace("{#institution#}", $institution, $body);
  74. $body = preg_replace("{#state#}", $state, $body);
  75. $body = preg_replace("{#city#}", $city, $body);
  76.  
  77. $mail->IsSMTP();
  78. $mail->SMTPAuth = true;
  79. $mail->SMTPSecure = "ssl";
  80. $mail->Host = "br276.hostgator.com.br";
  81. $mail->Port = 465;
  82.  
  83. $mail->Username = "mkt@escolacontrata.com.br";
  84. $mail->Password = "marketing1";
  85.  
  86. $mail->From = "mkt@escolacontrata.com.br";
  87. $mail->FromName = "Escola Contrata";
  88. $mail->Subject = 'Cupom de Desconto:' . $course;
  89. $mail->WordWrap = 50;
  90. $mail->MsgHTML($body);
  91. $mail->AddAddress('dop@escolacontrata.com.br', $institution);
  92. $mail->AddAddress('emerson@dopcomunicacao.com.br', 'Escola Contrata');
  93. $mail->CharSet = "UTF-8";
  94. $mail->IsHTML(true);
  95.  
  96. if($mail->Send()) {
  97. $error = true;
  98. } else {
  99. $error = $mail->ErrorInfo;
  100. }
  101. } catch(Exception $e){
  102. $error = $e->getMessage();
  103. } finally {
  104. echo json_encode(array('error' => $error));
  105. }
  106.  
  107. var_dump($param);
  108. die;
  109. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement