Dear All,
I am testing the latest PHPMailer with my email script, but i encounter an error “Parse error: syntax error, unexpected ‘use’ (T_USE) in C:\Program Files (x86)\NetMake\v81\wwwroot\scriptcase\app\EmailTest\control2\control2_apl.php on line 1472” when i executing the example where i get from web.
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
sc_include_library(“prj”, “PHPMailer”, “src/PHPMailer.php”);
sc_include_library(“prj”, “PHPMailer”, “src/SMTP.php”);
sc_include_library(“prj”, “PHPMailer”, “src/Exception.php”);
//sc_include_library(“prj”, “PHPMailer”, “vendor/autoload.php”); // replaces require ‘PHPMailerAutoload.php’;
$mail = new PHPMailer(true);
$mail->SMTPDebug = 2; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = ‘smtp.gmail.com’; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = ‘tcimem2017@gmail.com’; // SMTP username
$mail->Password = ‘xxxxxx’; // SMTP password
$mail->SMTPSecure = ‘tls’; // Enable TLS encryption, ssl
also accepted
$mail->Port = 587; // TCP port to connect to
$mail->setFrom(‘tcimem2017@gmail.com’,{Name_From});
$mail->addAddress({Email_To},{Name_To}); // Add a recipient
//$mail->addAddress(‘ellen@example.com’); // Name is optional
//$mail->addReplyTo(‘info@example.com’, ‘Information’);
//$mail->addCC(‘cc@example.com’);
//$mail->addBCC(‘bcc@example.com’);
//$mail->addAttachment(’/var/tmp/file.tar.gz’); // Add attachments
//$mail->addAttachment(’/tmp/image.jpg’, ‘new.jpg’); // Optional name
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = {Subject};
$mail->Body = {test};
$mail->AltBody = ‘This is the body in plain text for non-HTML mail clients’;
$mail->SMTPOptions = array( //OPTIEREGEL MOET ER STAAN ZONIET FOUTMELDING
‘ssl’ => array(
‘verify_peer’ => false,
‘verify_peer_name’ => false,
‘allow_self_signed’ => true
));
if(!$mail->send())
{
echo ‘Message could not be sent.’;
echo 'Mailer Error: ’ . $mail->ErrorInfo;
}
else
{
echo ‘Message has been sent’;
}
The original example i get from web.
<?php use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\Exception; require ‘path/to/PHPMailer/src/Exception.php’; require ‘path/to/PHPMailer/src/PHPMailer.php’; require ‘path/to/PHPMailer/src/SMTP.php’;