Advertisement
Guest User

Untitled

a guest
Feb 8th, 2018
433
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.79 KB | None | 0 0
  1. <?php
  2.  
  3. namespace App\Http\Controllers\Site;
  4.  
  5. use App\Models\Seo;
  6. use App\Models\Smtp;
  7. use Illuminate\Http\Request;
  8. use App\Http\Controllers\Controller;
  9. use PHPMailer;
  10.  
  11.  
  12. class ContatoController extends Controller
  13. {
  14. public function index()
  15. {
  16. return view('site.contato');
  17. }
  18.  
  19. public function mensagem(Request $request)
  20. {
  21.  
  22. $seo = Seo::first();
  23. $smtp = Smtp::first();
  24.  
  25. /*
  26. global $mail;
  27. $mail = new PHPMailer();
  28. $mail->IsSMTP();
  29. $mail->SMTPAuth = true;
  30. $mail->SMTPSecure = "tls";
  31. $mail->WordWrap = 80;
  32. $mail->IsHTML(true);
  33. $mail->Port = $smtp->port;
  34. $mail->Host = $smtp->host;
  35. $mail->Username = $smtp->username;
  36. $mail->From = $smtp->username;
  37. $mail->Password = $smtp->password;
  38. $mail->FromName = $smtp->fromname;
  39. $mail->Subject = utf8_decode("Contato Via Site " . $seo->title);
  40. $mail->AddBCC($smtp->bcc);
  41. $mail->AddAddress($smtp->username);
  42.  
  43. $data = date('d/m/Y H:i');
  44. $nome = $request->input('nome');
  45. $telefone = $request->input('telefone');
  46. $email = $request->input('email');
  47. $mensagem = $request->input('message');
  48.  
  49. $mail->AddReplyTo($request->input('email'));
  50. $body = "<b>Data da Mensagem: </b> $data <br />";
  51. $body .= "<b>Nome:</b> $nome <br />";
  52. $body .= "<b>Telefone:</b> $telefone <br />";
  53. $body .= "<b>E-mail:</b> $email <br />";
  54. $body .= "<b>Mensagem: </b> $mensagem <br />";
  55. $mail->Body = nl2br($body);
  56. $mail->SMTPOptions = array(
  57. 'ssl' => array(
  58. 'verify_peer' => false,
  59. 'verify_peer_name' => false,
  60. 'allow_self_signed' => true
  61. )
  62. );
  63. $mail->send();
  64. */
  65.  
  66.  
  67. $url = 'https://api.elasticemail.com/v2/email/send';
  68. try {
  69.  
  70. $data = date('d/m/Y H:i');
  71. $nome = $request->input('nome');
  72. $telefone = $request->input('telefone');
  73. $email = $request->input('email');
  74. $mensagem = $request->input('message');
  75. $body = "<b>Data da Mensagem: </b> $data <br />";
  76. $body .= "<b>Nome:</b> $nome <br />";
  77. $body .= "<b>Telefone:</b> $telefone <br />";
  78. $body .= "<b>E-mail:</b> $email <br />";
  79. $body .= "<b>Mensagem: </b> $mensagem <br />";
  80. $body = nl2br($body);
  81.  
  82. $seo = Seo::first();
  83. $post = array(
  84. 'from' => 'marcelo@ciaboat.com.br',
  85. 'fromName' => $seo->title,
  86. 'apikey' => 'a7be9bd0-671b-400b-b0ae-36450abbb5cf',
  87. 'subject' => "Contato Via Site",
  88. 'msgTo' => 'marcelo@ciaboat.com.br',
  89. //'msgBcc' => implode(";", $market),
  90. 'bodyHtml' => $body,
  91. 'bodyText' => 'ciaboat',
  92. 'isTransactional' => true);
  93. $ch = curl_init();
  94. curl_setopt_array($ch, array(
  95. CURLOPT_URL => $url,
  96. CURLOPT_POST => true,
  97. CURLOPT_POSTFIELDS => $post,
  98. CURLOPT_RETURNTRANSFER => true,
  99. CURLOPT_HEADER => false,
  100. CURLOPT_SSL_VERIFYPEER => false
  101. ));
  102. $result = curl_exec($ch);
  103. //echo $result;
  104. curl_close($ch);
  105. } catch (Exception $ex) {
  106. // echo $ex->getMessage();
  107. }
  108.  
  109.  
  110. return redirect()->back()->with('send', 'Obrigado sua mensagem foi entregue em breve retornaremos');
  111. }
  112. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement