0
Hey, guys! All right? This is my first post here. I’m in a bit of a silly problem, but three, four days ago! I started to develop recently and this is my first commercial project. It’s practically ready, but my email form isn’t working when the resolution is 360px (for smartphones). The funny thing is that it works for desktops, it works on laptops, tablets, but not for mobile. Another important information is that it is not local, it is already on server.
For the collection and sending of the information, I am using Phpmailer. I will pass the source codes to please take a look!
In addition to Phpmailer, I’m also using the slim Framework v2 and bootstrap 3.
CONTACT FORM - DESKTOPS
<div class="contato-Coluna1 col-sm-4 col-md-4 col-lg-4">
<h4>ENTRE EM CONTATO</h4>
<hr>
<form action="mail" method="POST">
<div class="form-group">
<input type="text" class="form-control" name="campoNome" placeholder="Nome: ">
</div>
<div class="form-group">
<input type="text" class="form-control" name="campoCidade" placeholder="Cidade: ">
</div>
<div class="form-group">
<input type="email" class="form-control" name="campoEmail" placeholder="Email: ">
</div>
<div class="form-group">
<input type="number" class="form-control" name="campoTelefone" placeholder="Telefone: ">
</div>
<div class="form-group">
<label for="comment">Deixe sua mensagem:</label>
<textarea class="form-control" rows="5" name="campoMensagem"></textarea>
</div>
<button type="submit" class="btn btn-primary" id="btnEnviarForm">Enviar</button>
</form>
</div>
SOURCE CODE MOBILE VERSION
<div class="mobileContato visible-xs visible-sm">
<h4 class="text-center">ENTRE EM CONTATO</h4>
<hr>
<form action="mail" method="POST">
<div class="form-group">
<input type="text" class="form-control" name="campoNome" placeholder="Nome: ">
</div>
<div class="form-group">
<input type="text" class="form-control" name="campoCidade" placeholder="Cidade: ">
</div>
<div class="form-group">
<input type="email" class="form-control" name="campoEmail" placeholder="Email: ">
</div>
<div class="form-group">
<input type="number" class="form-control" name="campoTelefone" placeholder="Telefone: ">
</div>
<div class="form-group">
<label for="comment">Deixe sua mensagem:</label>
<textarea class="form-control" rows="5" name="campoMensagem"></textarea>
</div>
<button type="submit" class="btn btn-primary" id="btnEnviarForm">Enviar</button>
</form>
</div>
PHPMAILER CONFIGURATION (I removed the information like emails and passwords here from the code, but in this part, it’s all right. So much so that, as I said, for desktop it sends).
$app->post(
'/mail',
function () {
$nome = $_POST['campoNome'];
$cidade = $_POST['campoCidade'];
$email = $_POST['campoEmail'];
$tel = $_POST['campoTelefone'];
$msg = $_POST['campoMensagem'];
$mensagem = "<strong>Nome: </strong>" . $nome . "<br>";
$mensagem .= "<strong>Cidade: </strong>" . $cidade . "<br>";
$mensagem .= "<strong>Email: </strong>" . $email . "<br>";
$mensagem .= "<strong>Telefone: </strong>" . $tel . "<br><br>";
$mensagem .= "<strong>Mensagem: </strong>" . "<br>" . $msg;
require_once("class/class.phpmailer.php");
$mail = new PHPMailer(true);
$mail->IsSMTP();
try {
$mail->Host = '' ; // Endereço do servidor SMTP (Autenticação, utilize o host smtp.seudomínio.com.br)
$mail->SMTPAuth = true; // Usar autenticação SMTP (obrigatório para smtp.seudomínio.com.br)
$mail->Port = 587; // Usar 587 porta SMTP
$mail->Username = ''; // Usuário do servidor SMTP (endereço de email)
$mail->Password = ''; // Senha do servidor SMTP (senha do email usado)
//Define o remetente
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
$mail->SetFrom('', ''); //Seu e-mail
$mail->AddReplyTo('', ''); //Seu e-mail
$mail->Subject = '' . $nome;//Assunto do e-mail
//Define os destinatário(s)
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
$mail->AddAddress('', '');
//Define o corpo do email
$mail->MsgHTML('corpo do email');
$mail->Body = $mensagem;
$mail->Send();
//caso apresente algum erro é apresentado abaixo com essa exceção.
} catch (phpmailerException $e) {
echo $e->errorMessage(); //Mensagem de erro costumizada do PHPMailer
}
});
If you can then help me in this, I will be very grateful because this is all missing to finish the project.
Thanks a lot!
Post the section that triggers the sending of the email...
– Sr. André Baill
Sorry @Pra! I could only see your message now! So actually for the desktop version there is a navigation link "Contact.php" where the person enters and there, in addition to the Google Maps map, has a contact form. This one is working normally. I tested and rerouted the messages to my particular email and are coming in normally. For the "mobile" version, I left the contact form already in the "index" with the intention of being something more objective. And that’s the one that won’t go at all. When you click send, it’s like you refresh the page, but it doesn’t send.
– Gus
@Andrébaill thanks for the answer, only that, in fact, it would be that part of phpmailer that sends, or am I wrong? Sorry my inexperience!
– Gus
Good night! All jewels? Exact, @ːvː, is EXACTLY that. I did the following (I will list to not confuse): 1. The idea is to have a confirmation for both desktop and mobile. 2. The desktop version works. If you submit, it gives a refresh and in the div that is the form, it is replaced by a successfully sending phrase. 3. In the case of mobile, I had done the same thing, but that doesn’t happen. When you click on "send", it gives the refresh, but it’s as if you have pressed F5. Does not appear the sending phrase and also does not send.
– Gus
(continuing the previous message) Yesterday I noticed something strange. For sending form data, I used the POST. Only on mobile, bizarrely, when you click "Send", it gives the refresh as I said, but it leaves the content in the browser’s address bar, as if it were a GET, but nowhere in the codes has the GET, especially for this. I only use the post. Since you are already helping me, to try to improve, I climbed the site on the server, if you want to take a look or do some test, feel free, the emails fall in my private email! www.sabconsel.com.br Valeu! :)
– Gus
Your evil has come here! = D
– Gus
Because it occurred to me that it might be some mail crash, some incompatibility. So I did a mobile action, only the codes are the same, actually. It was more to test, see if there could be any kind of incompatibility even. But the two are the same. I tried to leave the mail to both, but it didn’t work either. What intrigued me even more is this "GET" format in the address bar
– Gus
Another email came with the blank fields [for information purposes only]
– Gus
All right, I’ll do it! And I’ll leave it in the footer too or just in the same head?
– Gus
I put everything in the <head> and, due to doubts, I left commented everything that was on the footer ;)
– Gus
So, in theory it was not to influence, because theoretically, the form is passing the same information to the same place. I even use the same fields. He plays for the Slim Framework and this does the entire sending process using phpmailer. But honestly, I don’t rule that out! I think I’ll take a test then. In the mobile version, I wanted to make the site as direct as possible, but I will recreate the "contact" page and see if it works. If it works, besides my head give a final screw, ahaha, I will be very happy and I will put your name in the codes as thanks! kkkk
– Gus