Advertisement
Guest User

Untitled

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