PHP Mailer 'PHP Parse error'

Asked

Viewed 431 times

0

When using PHP Mailer it is returning me the following message

PHP Parse error: syntax error, Unexpected '[' in plugins Phpmailer src Phpmailer.php on line 288

My code as below

require 'plugins/PHPMailer/src/Exception.php';
require 'plugins/PHPMailer/src/PHPMailer.php';
require 'plugins/PHPMailer/src/SMTP.php';

$email = new PHPMailer();
$email->From      = '[email protected]';
$email->FromName  = 'Seu nome';
$email->Subject   = 'Assunto';
$email->Body      = 'Teste';
$email->AddAddress( '[email protected]' );

$file_to_attach = 'teste';
$email->AddAttachment( $file_to_attach , 'teste.pdf' );

$email->Send();

I downloaded from https://github.com/PHPMailer/PHPMailer

The reason for the error ?

  • The reason is that you are using an obsolete version of PHP. You need to change your PHP version to 5.4 or higher.

  • Thanks was just that, but when it runs appears error 500

No answers

Browser other questions tagged

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