Error sending form with PHP

Asked

Viewed 178 times

0

I created a script to send an email to my Gmail in PHP, but it is giving me an error when sending the form, ERROR 405 Not Allowed

This is my form:

<form action="email.php" method="post">
  <div class="cols">
    <div class="col">
      <div class="form-group">
        <input name="nome" type="text" placeholder="Nome" required>
      </div>
    </div>
    <div class="col">
      <div class="form-group">
        <input name="email" type="email" placeholder="Email" required>
      </div>
    </div>
    <div class="col">
      <div class="form-group">
        <input name="telefone" type="number" placeholder="Telefone">
      </div>
    </div>
    <div class="col">
      <div class="form-group">
        <select name="opcao">
          <option>Selecione uma opção</option>
          <option>Orçamento</option>
          <option>Duvidas Referente ao Serviço</option>
          <option>Outro</option>
        </select>
      </div>
    </div>
  </div>
  <div class="text-area">
    <textarea name="mensagem" placeholder="Escreva sua mensagem"></textarea>
  </div>

  <div class "form-group">
    <button class="botao medio"><i class="fa fa-envelope" aria-hidden="true"></i> Enviar</button>
  <div>

And this is my script email php.

<?php

$nome       =   $_POST["nome"];
$email      =   $_POST["email"];
$telefone   =   $_POST["telefone"];
$assunto    =   $_POST["opcao"];
$mensagem   =   $_POST["mensagem"];

include("class.phpmailer.php");
include("class.smtp.php");

$mail = new PHPMailer();

$mail->SMTP_PORT = "587";
$mail->SMTPSecure = "tls";

$mail->IsSMTP();
$mail->Host = "smtp.gmail.com";
$mail->SMTPAuth = true;

$mail->Username = '[email protected]';
$mail->Password = 'minhasenha';

$mail->From = $email;
$mail->FromName = $nome;

$mail->AddAddress($email, $nome);
$mail->AddCC('[email protected]', 'Auto-Jet');

$mail->IsHTML(true);  

$mail->Subject = $assunto
$mail->Body = $mensagem;

$enviado = $mail->Send();

if ($enviado) {
    echo "Email Enviado com Sucesso";
}   else { 
    echo "Não foi Posssivel Enviar sua Mensagem";
}

?>
  • Error 405 gives in file email.php? What is the message in the server log?

  • yes error in email.php, I put my website in git hub pages

  • 2

    But Github Pages does not have PHP support. To run this, you will need a web server that supports this language.

  • in case I have to hire a hosting service ?

  • Yes, you’ll have to hire a service of this nature.

  • Gee .. I thought I’d be free of kkk lodgings, Thank you very much for the reply

  • and even if you supported php your script contains an error that would generate a PHP Parse error: syntax error. Missing ; on this line $mail->Subject = $subject

  • Really missed, Thanks, how can I close this post ?

Show 3 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.