Advertisement
Guest User

Untitled

a guest
Jan 26th, 2017
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.63 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. // echo 'Message could not be sent.';
  41. // echo 'Mailer Error: ' . $mail->ErrorInfo;
  42. } else {
  43. $error = $mail->ErrorInfo;
  44. // echo 'Message has been sent';
  45. }
  46. } catch(Exception $e){
  47. $error = $e->getMessage();
  48. } finally {
  49. echo json_encode(array('error' => $error));
  50. }
  51. }
  52.  
  53. public function sendEnrollmentRedirect(){
  54.  
  55. try {
  56. $name = $this->input->post('name');
  57. $email = $this->input->post('mail');
  58. $cpf = $this->input->post('cpf');
  59. $institution = $this->input->post('institution');
  60. $institutionMail = $this->input->post('institutionMail');
  61. $coupon = $this->input->post('coupon');
  62. $course = $this->input->post('course');
  63. $state = $this->input->post('state');
  64. $city = $this->input->post('city');
  65.  
  66. $mail = new PHPMailer();
  67.  
  68. $body = file_get_contents('assets/template/send_enrollment_redirect.html');
  69. $body = preg_replace("{#name#}", $name, $body);
  70. $body = preg_replace("{#email#}", $email, $body);
  71. $body = preg_replace("{#cpf#}", $cpf, $body);
  72. $body = preg_replace("{#coupon#}", $coupon, $body);
  73. $body = preg_replace("{#course#}", $course, $body);
  74. $body = preg_replace("{#institution#}", $institution, $body);
  75. $body = preg_replace("{#state#}", $state, $body);
  76. $body = preg_replace("{#city#}", $city, $body);
  77.  
  78. $mail->IsSMTP();
  79. $mail->SMTPAuth = true;
  80. $mail->SMTPSecure = "ssl";
  81. $mail->Host = "br276.hostgator.com.br";
  82. $mail->Port = 465;
  83.  
  84. $mail->Username = "mkt@escolacontrata.com.br";
  85. $mail->Password = "marketing1";
  86.  
  87. $mail->From = "mkt@escolacontrata.com.br";
  88. $mail->FromName = "Escola Contrata";
  89. $mail->Subject = 'Cupom de Desconto:' . ' ' . $course;
  90. $mail->WordWrap = 50;
  91. $mail->MsgHTML($body);
  92. $mail->AddAddress('dop@escolacontrata.com.br', $institution);
  93. $mail->AddAddress('emerson@dopcomunicacao.com.br', 'Escola Contrata');
  94. $mail->CharSet = "UTF-8";
  95. $mail->IsHTML(true);
  96.  
  97. if($mail->Send()) {
  98. $error = true;
  99. // echo 'Message could not be sent.';
  100. // echo 'Mailer Error: ' . $mail->ErrorInfo;
  101. } else {
  102. $error = $mail->ErrorInfo;
  103. // echo 'Message has been sent';
  104. }
  105. } catch(Exception $e){
  106. $error = $e->getMessage();
  107. } finally {
  108. echo json_encode(array('error' => $error));
  109. }
  110. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement