Reputation: 1
I've installed phpMailer 6.5.1 under PHP 7.3.21 (Wampserver). I've used the example given on their site to send a simple mail and it works correctly.
When I copy both phpMailer and my script on production under PHP 5.4.20, I have the error "can't use function return value in write context in src/PHPMailer on line 1700".
That error appear just after including that file.
Thank you for your ideas!
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
use PHPMailer\PHPMailer\Exception;
require 'librairies/vendor/phpmailer/phpmailer/src/Exception.php';
require 'librairies/vendor/phpmailer/phpmailer/src/PHPMailer.php'; **error here**
require 'librairies/vendor/phpmailer/phpmailer/src/SMTP.php';
require 'librairies/vendor/autoload.php';
$mail = new PHPMailer();
$mail->SMTPDebug = SMTP::DEBUG_CONNECTION;
$mail->IsSMTP();
$mail->Host = 'host'; //Adresse IP ou DNS du serveur SMTP
$mail->Port = 587; //Port TCP du serveur SMTP
$mail->SMTPAuth = true; //Utiliser l'identification
if($mail->SMTPAuth){
// $mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS; //Protocole de sécurisation des échanges avec le SMTP
$mail->Username = 'user'; //Adresse email à utiliser
$mail->Password = 'pass'; //Mot de passe de l'adresse email à utiliser
}
$mail->CharSet = 'UTF-8'; //Format d'encodage à utiliser pour les caractères
$mail->smtpConnect();```
Upvotes: 0
Views: 675
Reputation: 398
PhpMailer 6.5.1 is not compatible with your server-side PHP version (5.4.2). Either you upgrade the PHP on your server to at least 5.5 or you use a legacy version of PHMailer. See PHPMailer installation notes below.
PHPMailer 5.2 (which is compatible with PHP 5.0 — 7.0) is no longer supported, even for security updates. You will find the latest version of 5.2 in the 5.2-stable branch. If you're using PHP 5.5 or later (which you should be), switch to the 6.x releases.
https://github.com/PHPMailer/PHPMailer#legacy-versions
Upvotes: 1