Advertisement
Guest User

Untitled

a guest
Jul 31st, 2017
498
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.98 KB | None | 0 0
  1. <?php
  2.           ini_set('magic_quotes_runtime', 0);
  3.           $nome     = strip_tags(trim($_POST['nome']));
  4.           $email    = strip_tags(trim($_POST['email']));
  5.           $telefone = strip_tags(trim($_POST['telefone']));
  6.           $titulo   = strip_tags(trim($_POST['titulo']));
  7.           $mensagem = strip_tags(trim($_POST['mensagem']));
  8.           $arquivo  = $_FILES['arquivo'];
  9.        
  10.           if(empty($nome)){
  11.             $msg = 'O Nome é Obrigatório';
  12.           }elseif(!filter_var($email, FILTER_VALIDATE_EMAIL)){
  13.             $msg = 'Digite um E-mail válido';
  14.           }elseif(empty($titulo)){
  15.             $msg = 'O Título é Obrigatório';
  16.           }elseif(empty($mensagem)){
  17.             $msg = 'A Mensagem é Obrigatória';
  18.          }else{
  19.             require('PHPMailer/class.phpmailer.php');
  20.            
  21.            $mail = new PHPMailer();
  22.            $mail->IsSMTP();
  23.            $mail->SMTPAuth = true;
  24.            $mail->Port = 587;
  25.            $mail->Host = 'smtp.igsol.org';
  26.            $mail->Username = 'usuario';
  27.            $mail->Password = 'senha';
  28.            $mail->From = 'renato@igsol.org';
  29.            $mail->FromName = 'Contato-Site';
  30.            $mail->AddAddress('igsol@igsol.org', 'Instituto Gira-Sol');
  31.            $mail->Subject = 'Formulario de Contato';
  32.            
  33.            $body = "<strong>Nome :</strong>{$nome} <br />
  34.                <strong>E-mail :</strong>{$email} <br />
  35.                 <strong>Telefone :</strong>{$telefone}<br />
  36.                <strong>Titulo :</strong>{$titulo} <br />
  37.                <strong>Mensagem :</strong>{$mensagem} <br />
  38.                <strong>Arquivo :</strong> ".$arquivo['name'];
  39.            $mail->MsgHTML($body);
  40.            if(is_uploaded_file($arquivo['tmp_name'])){
  41.                 $mail->AddAttachment( $arquivo['tmp_name'],  $arquivo['name']);
  42.           }
  43.                
  44.            if($mail->Send()){
  45.                $msg = 'Sua Mensagem foi enviada com Sucesso!!!';
  46.             }else{
  47.                $msg = 'Sua Mensagem não foi enviada, tente novamente';
  48.            }
  49.            
  50.           }
  51. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement