I am tasked to upgrade the currently implemented PHPMailer version 5.2.4 classes to the latest stable version of these classes for an ecommerce web application that is being migrated from PHP 5.6 to PHP 7.2.
The site has been using PHPMailer version 5.2.4 and its related classes installed without using Composer without any issue for many years to generate transaction emails that are sent via a 3rd party SMTP email provider.
I would like to upgrade the PHPMailer 5.2.4 classes to the latest stable version and to continue to use the classes in the code without deploying them via Composer.
I am aware that as of PHPMailer version 6.0 that a namespace needs to be added to the code.
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
use PHPMailer\PHPMailer\SMTP;
require 'src/Exception.php';
require 'src/PHPMailer.php';
require 'src/SMTP.php';
I went to the PHPMailer project on GitHub and downloaded the following files from the GitHub Master Branch:
https://github.com/PHPMailer/PHPMailer/tree/master/src
src/PHPMailer.php
src/Exception.php
src/SMTP.php
I added the necessary namespaces to my existing code that uses these classes; and I also updated my existing exception handling code that was previously catching exceptions of type phpmailerException to now use the PHPMailer Exception Class namespace, and any existing Exception references use the global namespace;
...
try {
...
} catch (Exception $e) {
//$e is an instance of PHPMailer\PHPMailer\Exception
echo $e->errorMessage();
} catch (\Exception $e) {
//$e is an instance of the PHP built-in Exception class
echo $e->getMessage();
}
After making these updates everything worked fine to generate emails in my development environment running PHP version 7.2.
I am ready to deploy the update to my site's Production/live server and would like to confirm that I have used the latest stable fully tested versions of the PHPMailer classes.
I just have a somewhat silly question/concern:
When using PHPMailer classes without using Composer I read in several tutorials to download these classes from the PHPMailer GitHub Project's Master Branch src.
However, I also read in some tutorials to use Version 6.0 of PHPMailer. In addition, I seem to recall reading somewhere that the master branch is not guaranteed to be stable.
MY QUESTION: Was it correct that I used the GitHub Master Branch src to download the PHPMailer classes for use in my website if I wanted the latest stable fully tested versions of these clases?
Or perhaps, should I use the GitHub 6.0 Branch src to download these class files?
Adding to my confusion, I see that the only branch that is specifically labeled "stable" is the GitHub "5.2 Stable" Branch and its latest version is 5.2.27.
On a related note, can you please clarify the following in the Master Branch:
**src/SMTP.php**
(has const VERSION = '6.0.6';)
**src/Exception.php**
Is there a reason that comments or code in this file does not mention Version 6.0.6?
**src/PHPMailer.php**
Is there a reason that comments or code in this file does not mention Version 6.0.6?
Thank you very much for your help.