phpmailer with gmail

Asked

Viewed 178 times

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";
?>

inserir a descrição da imagem aqui

  • 1

    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.

  • This error shows a line... You can post this line and the previous two and later here please?

  • 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

  • 1

    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.

  • I added an error line image....

  • 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...

  • I can’t see the xD image

  • Just click on the image and it zooms in

  • Her domain is locked (proxy), so I can’t see.

  • http://i.stack.Imgur.com/xm2FP.png locked there in your company?

  • I tried to download several codes from Github, but they don’t work properly... Each gives an error.

  • @Felipejorge Have you tried this online and not locally?

  • Already, the syntax error gives online and not locally. Locally does not give syntax error.

Show 9 more comments
No answers

Browser other questions tagged

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