-1
Well I have a problem in phpmailer I am using a XAMPP server to mess with it I made a form but it is sending normally to my email that in case it would be GMAIL however I have a hosting on the localweb and when I put my site in the air and fill mine form it gives the following error:
Parse error: syntax error, unexpected T_FUNCTION in /home/storage/1/8e/5d/tecmovgruas2/public_html/phpmailer/class.phpmailer.php on line 3040
code snippet of line 3040 that appears in error:
protected function clearQueuedAddresses($kind)
{
if (version_compare(PHP_VERSION, '5.3.0', '<')) {
$RecipientsQueue = $this->RecipientsQueue;
foreach ($RecipientsQueue as $address => $params) {
if ($params[0] == $kind) {
unset($this->RecipientsQueue[$address]);
}
}
} else {
$this->RecipientsQueue = array_filter(
$this->RecipientsQueue,
function ($params) use ($kind) {
return $params[0] != $kind;
});
}
}
remember that I am not using this file follows my PHP code and an excerpt from the form of my site:
THE HTML:
<form id="main-contact-form1" name="contact-form" action="envio.php" method="post">
<div class="row wow fadeInUp" data-wow-duration="1000ms" data-wow-delay="300ms">
<div class="col-sm-6">
<div class="form-group">
<input type="text" name="name" class="form-control" placeholder="Nome" required="required">
</div>
</div>
<div class="col-sm-6">
<div class="form-group">
<input type="email" name="email" class="form-control" placeholder="E-mail" required="required">
</div>
</div>
</div>
<div class="form-group">
<input type="text" name="subject" class="form-control" placeholder="Assunto" required="required">
</div>
<div class="form-group">
<textarea name="message" id="message" class="form-control" rows="4" placeholder="Escreva sua Mensagem" required="required"></textarea>
</div>
<div class="form-group">
<button type="submit" class="btn-submit">Enviar</button>
</div>
</form>
PHP:
<?php
$Nome = $_POST["name"]; // Pega o valor do campo Nome
$Email = $_POST["email"]; // Pega o valor do campo Telefone
$Assunto = $_POST["subject"]; // Pega o valor do campo Email
$Mensagem = $_POST["message"]; // Pega os valores do campo Mensagem
// Variável que junta os valores acima e monta o corpo do email
$Vai = "Nome: $Nome\n\nE-mail: $Email\n\nAssunto: $Assunto\n\nMensagem: $Mensagem\n";
/*date_default_timezone_set('Etc/UTC');
*/
require("phpmailer/PHPMailerAutoload.php");
require("phpmailer/class.smtp.php");
define('GUSER', '[email protected]'); // <-- Insira aqui o seu GMail
define('GPWD', 'lalala'); // <-- Insira aqui a senha do seu GMail
function smtpmailer($para, $de, $de_nome, $assunto, $corpo) {
global $error;
$mail = new PHPMailer();
$mail->setLanguage('pt');
$mail->IsSMTP(); // Ativar SMTP
$mail->SMTPDebug = 0; // Debugar: 1 = erros e mensagens, 2 = mensagens apenas
$mail->SMTPAuth = true; // Autenticação ativada
$mail->SMTPSecure = 'tsl'; // SSL REQUERIDO pelo GMail
$mail->Host = 'smtp.tecmovgruas.com'; // SMTP utilizado
$mail->Port = 587; // A porta 587 deverá estar aberta em seu servidor
$mail->Username = GUSER;
$mail->Password = GPWD;
$mail->SetFrom($de, $de_nome);
$mail->Subject = $assunto;
$mail->Body = $corpo;
$mail->AddAddress($para);
if(!$mail->Send()) {
$error = 'Mail error: '.$mail->ErrorInfo;
return false;
} else {
$error = 'Mensagem enviada!';
return true;
}
}
// Insira abaixo o email que irá receber a mensagem, o email que irá enviar (o mesmo da variável GUSER),
if (smtpmailer('[email protected]', '[email protected]', 'renata', 'Assunto do Email', $Vai)) {
Header("location:obrigado.html"); // Redireciona para uma página de obrigado.
}
if (!empty($error)) echo $error;
?>
NOTE: It is worth remembering that this is working perfectly local with xampp only when I upload the project to the web it stops working. And I also created my own email domain on the localweb where my email goes there and is redirected to my gmail account
Your local xampp php may differ from the hosted server php. some other things of hosting may be disabled smtp,email port 587 various other problems.
– TutiJapa Wada
I’ll take a look here
– Felipe Henrique
I don’t think it’s a DOOR problem... The weird thing is that it should fix the problem:
if (version_compare(PHP_VERSION, '5.3.0', '<')) {
, I really don’t know why this is happening, what version of your server?– Guilherme Nascimento
the serividor xampp Voce says ? if it is and version 3.2.2
– Felipe Henrique
Xampp is not a package of programs and is not official PHP, it is only a facilitator, it can have more than one version of php, what I want to know is the version of php installed in the hosting @Kirito - Creates a script called info.php and puts this content
<?php echo phpinfo();
and then run and find out where the version says and let me know.– Guilherme Nascimento
so man and this is the version PHP Version 5.6.15
– Felipe Henrique
There seems to be no problem with what you presented. Remember that the PHP compiler can point out the error in a "wrong" line when there are errors
if () else
. Usually when there’s a{
or(
open. It may also be the lack of the line delimiter;
at some point in the scripts before the line pointed to by the error. The error may not even be in the Phpmailier codes. You should create breakpoints by searching for logical points to eliminate the possibility of errors until you find the location.– Daniel Omine