Guest User

Matheus Souza Rigote

a guest
Feb 22nd, 2010
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.29 KB | None | 0 0
  1. <?php
  2.    
  3.     //recuperando dados do formul�rio
  4.     $empresa  = strip_tags(trim($_POST['empresa']));
  5.     $nome     = strip_tags(trim($_POST['nome']));
  6.     $telefone = strip_tags(trim($_POST['telefone']));
  7.     $email    = strip_tags(trim($_POST['email']));
  8.     $estado   = strip_tags(trim($_POST['estado']));
  9.     $mensagem = strip_tags(trim($_POST['mensagem']));
  10.     $arquivo  = $_FILES['arquivo'];
  11.    
  12.     header('Content-Type: text/html; charset=UTF-8');
  13.    
  14.     $tamanho  = 2097152;
  15.     $tipos    = array('image/jpeg', 'image/pjpeg');
  16.    
  17.     if(empty($empresa)){
  18.     $msg = �O Nome � Obrigat�rio�;
  19.     }elseif(empty($nome)){
  20.     $msg = �O T�tulo � Obrigat�rio�;
  21.     }elseif(empty($telefone)){
  22.     $msg = �O T�tulo � Obrigat�rio�;
  23.     }elseif(!filter_var($email, FILTER_VALIDATE_EMAIL)){
  24.     $msg = �Digite um E-mail v�lido�;
  25.     }elseif(empty($estado)){
  26.     $msg = �O T�tulo � Obrigat�rio�;
  27.     }elseif(empty($mensagem)){
  28.     $msg = �A Mensagem � Obrigat�ria�;
  29.     }elseif($arquivo['size'] > $tamanho){
  30.     $msg = �O limite do tamanho do arquivo � de 2MB�;
  31.     }elseif(!in_array($arquivo['type'], $tipos)){
  32.     $msg = �O tipo do arquivo permitido � apenas JPEG�;
  33.     }else{
  34.        require('PHPMailer/class.phpmailer.php');
  35.      
  36.       $mail = new PHPMailer();
  37.       $mail->IsSMTP();
  38.       $mail->SMTPAuth = true;
  39.       $mail->Port = 25;
  40.       $mail->Host = 'meuhost.com.br';
  41.       $mail->Username = 'usuario';
  42.       $mail->Password = 'senha';  
  43.       $mail->SetFrom('[email protected]', 'Matheus');
  44.       $mail->AddAddress('[email protected]', 'Matheus UOL');
  45.       $mail->Subject = 'Formul�rio de Contato';
  46.  
  47.       $body = "<strong>Empresa : </strong>{$empresa} <br />
  48.          <strong>Nome : </strong>{$nome} <br />
  49.           <strong>Telefone : </strong>{$telefone} <br />
  50.          <strong>E-mail : </strong>{$email} <br />
  51.           <strong>Estado : </strong>{$estado} <br />
  52.          <br>{$mensagem}";
  53.           //<strong>Arquivo : </strong> ".$arquivo['name'];
  54.      
  55.          
  56.       $mail->MsgHTML($body);
  57.       $mail->AddAttachment($arquivo['tmp_name'], $arquivo['name']);
  58.      
  59.       if($mail->Send())
  60.           echo "<meta HTTP-EQUIV='Refresh' CONTENT='0;URL=http://www.fidelity.com.br/form fidelity/obrigado.html'>";
  61.        else
  62.           echo "<meta HTTP-EQUIV='Refresh' CONTENT='0;URL=http://www.fidelity.com.br/intranet'>";
  63.      
  64.       }
  65.      
  66.  
  67. ?>
Advertisement
Add Comment
Please, Sign In to add comment