Advertisement
Guest User

Untitled

a guest
Jun 14th, 2017
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.72 KB | None | 0 0
  1. 1.
  2. <?php
  3. 2.
  4. $nome = strip_tags(trim($_POST['nome']));
  5. 3.
  6. $email = strip_tags(trim($_POST['email']));
  7. 4.
  8. $titulo = strip_tags(trim($_POST['titulo']));
  9. 5.
  10. $mensagem = strip_tags(trim($_POST['mensagem']));
  11. 6.
  12. $arquivo = $_FILES['arquivo'];
  13. 7.
  14.  
  15. 8.
  16. $tamanho = 512000;
  17. 9.
  18. $tipos = array('image/jpeg', 'image/pjpeg');
  19. 10.
  20.  
  21. 11.
  22. if(empty($nome)){
  23. 12.
  24. $msg = 'O Nome � Obrigat�rio';
  25. 13.
  26. }elseif(!filter_var($email, FILTER_VALIDATE_EMAIL)){
  27. 14.
  28. $msg = 'Digite um E-mail v�lido';
  29. 15.
  30. }elseif(empty($titulo)){
  31. 16.
  32. $msg = 'O T�tulo � Obrigat�rio';
  33. 17.
  34. }elseif(empty($mensagem)){
  35. 18.
  36. $msg = 'A Mensagem � Obrigat�ria';
  37. 19.
  38. }elseif(!is_uploaded_file($arquivo['tmp_name'])){
  39. 20.
  40. $msg = 'O Arquivo � Obrigat�rio';
  41. 21.
  42. }elseif($arquivo['size'] > $tamanho){
  43. 22.
  44. $msg = 'O limite do tamanho do arquivo � de 500KB';
  45. 23.
  46. }elseif(!in_array($arquivo['type'], $tipos)){
  47. 24.
  48. $msg = 'O tipo do arquivo permitido � apenas JPEG';
  49. 25.
  50. }else{
  51. 26.
  52. require('PHPMailer/class.phpmailer.php');
  53. 27.
  54.  
  55. 28.
  56. $mail = new PHPMailer();
  57. 29.
  58. $mail->IsSMTP();
  59. 30.
  60. $mail->SMTPAuth = true;
  61. 31.
  62. $mail->Port = 587;
  63. 32.
  64. $mail->Host = 'smtp.topagitus.com.br';
  65. 33.
  66. $mail->Username = 'contato=topagitus.com.br';
  67. 34.
  68. $mail->Password = 'xxxxxxx';
  69. 35.
  70. $mail->SetFrom('contato@topagitus.com.br', 'Aislan');
  71. 36.
  72. $mail->AddAddress('teste@topagitus.com.br, 'Aislan Renedy');
  73. 37.
  74. $mail->Subject = 'Formul�rio de Contato';
  75. 38.
  76.  
  77. 39.
  78. $body = "<strong>Nome :</strong>{$nome} <br />
  79. 40.
  80. <strong>E-mail :</strong>{$email} <br />
  81. 41.
  82. <strong>Titulo :</strong>{$titulo} <br />
  83. 42.
  84. <strong>Mensagem :</strong>{$mensagem} <br />
  85. 43.
  86. <strong>Arquivo :</strong> ".$arquivo['name'];
  87. 44.
  88.  
  89. 45.
  90. $mail->MsgHTML($body);
  91. 46.
  92. $mail->AddAttachment($arquivo['tmp_name'], $arquivo['name']);
  93. 47.
  94.  
  95. 48.
  96. if($mail->Send())
  97. 49.
  98. $msg = 'Sua Mensagem foi enviada com Sucesso!!!';
  99. 50.
  100. else
  101. 51.
  102. $msg = 'Sua Mensagem n�o foi enviada, tente novamente';
  103. 52.
  104.  
  105. 53.
  106. }
  107. 54.
  108.  
  109. 55.
  110. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement