Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace App\Http\Controllers\Site;
- use App\Models\Seo;
- use App\Models\Smtp;
- use Illuminate\Http\Request;
- use App\Http\Controllers\Controller;
- use PHPMailer;
- class ContatoController extends Controller
- {
- public function index()
- {
- return view('site.contato');
- }
- public function mensagem(Request $request)
- {
- $seo = Seo::first();
- $smtp = Smtp::first();
- /*
- global $mail;
- $mail = new PHPMailer();
- $mail->IsSMTP();
- $mail->SMTPAuth = true;
- $mail->SMTPSecure = "tls";
- $mail->WordWrap = 80;
- $mail->IsHTML(true);
- $mail->Port = $smtp->port;
- $mail->Host = $smtp->host;
- $mail->Username = $smtp->username;
- $mail->From = $smtp->username;
- $mail->Password = $smtp->password;
- $mail->FromName = $smtp->fromname;
- $mail->Subject = utf8_decode("Contato Via Site " . $seo->title);
- $mail->AddBCC($smtp->bcc);
- $mail->AddAddress($smtp->username);
- $data = date('d/m/Y H:i');
- $nome = $request->input('nome');
- $telefone = $request->input('telefone');
- $email = $request->input('email');
- $mensagem = $request->input('message');
- $mail->AddReplyTo($request->input('email'));
- $body = "<b>Data da Mensagem: </b> $data <br />";
- $body .= "<b>Nome:</b> $nome <br />";
- $body .= "<b>Telefone:</b> $telefone <br />";
- $body .= "<b>E-mail:</b> $email <br />";
- $body .= "<b>Mensagem: </b> $mensagem <br />";
- $mail->Body = nl2br($body);
- $mail->SMTPOptions = array(
- 'ssl' => array(
- 'verify_peer' => false,
- 'verify_peer_name' => false,
- 'allow_self_signed' => true
- )
- );
- $mail->send();
- */
- $url = 'https://api.elasticemail.com/v2/email/send';
- try {
- $data = date('d/m/Y H:i');
- $nome = $request->input('nome');
- $telefone = $request->input('telefone');
- $email = $request->input('email');
- $mensagem = $request->input('message');
- $body = "<b>Data da Mensagem: </b> $data <br />";
- $body .= "<b>Nome:</b> $nome <br />";
- $body .= "<b>Telefone:</b> $telefone <br />";
- $body .= "<b>E-mail:</b> $email <br />";
- $body .= "<b>Mensagem: </b> $mensagem <br />";
- $body = nl2br($body);
- $seo = Seo::first();
- $post = array(
- 'from' => 'marcelo@ciaboat.com.br',
- 'fromName' => $seo->title,
- 'apikey' => 'a7be9bd0-671b-400b-b0ae-36450abbb5cf',
- 'subject' => "Contato Via Site",
- 'msgTo' => 'marcelo@ciaboat.com.br',
- //'msgBcc' => implode(";", $market),
- 'bodyHtml' => $body,
- 'bodyText' => 'ciaboat',
- 'isTransactional' => true);
- $ch = curl_init();
- curl_setopt_array($ch, array(
- CURLOPT_URL => $url,
- CURLOPT_POST => true,
- CURLOPT_POSTFIELDS => $post,
- CURLOPT_RETURNTRANSFER => true,
- CURLOPT_HEADER => false,
- CURLOPT_SSL_VERIFYPEER => false
- ));
- $result = curl_exec($ch);
- //echo $result;
- curl_close($ch);
- } catch (Exception $ex) {
- // echo $ex->getMessage();
- }
- return redirect()->back()->with('send', 'Obrigado sua mensagem foi entregue em breve retornaremos');
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement