0
Hello, I’m trying to send email with PHP Mailer... but is giving error...
Parse error: syntax error, Unexpected end of file, expecting variable (T_VARIABLE) or '$' in C: Inetpub wwwroot Try phpmailer class.phpmailer.php online 2807
I have tried several times to use this e-mail function and always gives error. Someone knows how I fix it?
I know there are other posts with PHPMAILER but mine differs because it is an error that is different in all other posts.
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
$Vai = "exemplo de texto a enviar";
echo "a";
require_once("phpmailer/class.phpmailer.php");
echo "b";
define('GUSER', '[email protected]'); // <-- Insira aqui o seu GMail
define('GPWD', 'mypassword'); // <-- Insira aqui a senha do seu GMail
function smtpmailer($para, $de, $de_nome, $assunto, $corpo) {
global $error;
$mail = new PHPMailer();
$mail->IsSMTP(); // Ativar SMTP
$mail->SMTPDebug = 0; // Debugar: 1 = erros e mensagens, 2 = mensagens apenas
$mail->SMTPAuth = true; // Autenticação ativada
$mail->SMTPSecure = 'ssl'; // SSL REQUERIDO pelo GMail
$mail->Host = 'smtp.gmail.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;
}
}
echo "c";
if (smtpmailer('[email protected]', '[email protected]', 'Felipe Jorge Sales da Silva', 'Assunto do Email', $Vai)) {
echo "email enviado com sucesso";
Header("location:http://www.dominio.com.br/obrigado.html"); // Redireciona para uma página de obrigado.
}
if (!empty($error)) echo $error;
echo "não enviado";
?>
You need to check the error line or the previous one. It is a syntax error. Avoid using legacy libraries (no updates) or of dubious quality.
– rray
This error shows a line... You can post this line and the previous two and later here please?
– KhaosDoctor
I downloaded Phpmailer... This line I did not do. I just did what is in the code there, the rest is standard PHP folder Mailer
– Felipe Jorge
This error should not exist, you can download the recent version and see if it works without this 'bug', do not forget to check its requirements such as php version or edit the question and add the error line (2807) and the previous one.
– rray
I added an error line image....
– Felipe Jorge
I added an image with the line that is giving error... If you can help me or send a library that works I appreciate it. Because this is difficult...
– Felipe Jorge
I can’t see the xD image
– rray
Just click on the image and it zooms in
– Felipe Jorge
Her domain is locked (proxy), so I can’t see.
– rray
http://i.stack.Imgur.com/xm2FP.png locked there in your company?
– Felipe Jorge
Let’s go continue this discussion in chat.
– Felipe Jorge
I tried to download several codes from Github, but they don’t work properly... Each gives an error.
– Felipe Jorge
@Felipejorge Have you tried this online and not locally?
– caiocafardo
Already, the syntax error gives online and not locally. Locally does not give syntax error.
– Felipe Jorge