Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 1.
- <?php
- 2.
- $nome = strip_tags(trim($_POST['nome']));
- 3.
- $email = strip_tags(trim($_POST['email']));
- 4.
- $titulo = strip_tags(trim($_POST['titulo']));
- 5.
- $mensagem = strip_tags(trim($_POST['mensagem']));
- 6.
- $arquivo = $_FILES['arquivo'];
- 7.
- 8.
- $tamanho = 512000;
- 9.
- $tipos = array('image/jpeg', 'image/pjpeg');
- 10.
- 11.
- if(empty($nome)){
- 12.
- $msg = 'O Nome � Obrigat�rio';
- 13.
- }elseif(!filter_var($email, FILTER_VALIDATE_EMAIL)){
- 14.
- $msg = 'Digite um E-mail v�lido';
- 15.
- }elseif(empty($titulo)){
- 16.
- $msg = 'O T�tulo � Obrigat�rio';
- 17.
- }elseif(empty($mensagem)){
- 18.
- $msg = 'A Mensagem � Obrigat�ria';
- 19.
- }elseif(!is_uploaded_file($arquivo['tmp_name'])){
- 20.
- $msg = 'O Arquivo � Obrigat�rio';
- 21.
- }elseif($arquivo['size'] > $tamanho){
- 22.
- $msg = 'O limite do tamanho do arquivo � de 500KB';
- 23.
- }elseif(!in_array($arquivo['type'], $tipos)){
- 24.
- $msg = 'O tipo do arquivo permitido � apenas JPEG';
- 25.
- }else{
- 26.
- require('PHPMailer/class.phpmailer.php');
- 27.
- 28.
- $mail = new PHPMailer();
- 29.
- $mail->IsSMTP();
- 30.
- $mail->SMTPAuth = true;
- 31.
- $mail->Port = 587;
- 32.
- $mail->Host = 'smtp.topagitus.com.br';
- 33.
- $mail->Username = 'contato=topagitus.com.br';
- 34.
- $mail->Password = 'xxxxxxx';
- 35.
- $mail->SetFrom('contato@topagitus.com.br', 'Aislan');
- 36.
- $mail->AddAddress('teste@topagitus.com.br, 'Aislan Renedy');
- 37.
- $mail->Subject = 'Formul�rio de Contato';
- 38.
- 39.
- $body = "<strong>Nome :</strong>{$nome} <br />
- 40.
- <strong>E-mail :</strong>{$email} <br />
- 41.
- <strong>Titulo :</strong>{$titulo} <br />
- 42.
- <strong>Mensagem :</strong>{$mensagem} <br />
- 43.
- <strong>Arquivo :</strong> ".$arquivo['name'];
- 44.
- 45.
- $mail->MsgHTML($body);
- 46.
- $mail->AddAttachment($arquivo['tmp_name'], $arquivo['name']);
- 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