Installing PHPMailer with Composer
Composer is a dependency manager for PHP that you can use to install packages required by a PHP project. To install PHPMailer using Composer, follow these steps:- Log in to your account using SSH.
-
Change the directory to where you want to use the PHPMailer project. The location can be the document root of a domain as shown, or a subdirectory:
-
To install PHPMailer, type the following command:
📘 Note Composer suggests other packages to install, but they are not needed for this example.
Testing the PHPMailer installation
To test the installation, follow these steps:-
Create a PHP file to test the installation. You can create the file with the editor of your choice. In this procedure we use vi, but you can also use other command line editors or the graphical editor in your control panel. The file is named mailer.php in this example, but it can be any name ending in .php.
-
Type (or paste) the following code into the editor. Replace the email addresses and password with the actual values for your account and save the file:
-
Test the setup by running the file from the command line or visiting the page in your web browser. The command line is shown below.
Installing PHPMailer with Git
Git is a version-control system that can be also be used to install software. To install PHPMailer using Git, follow these steps:- Log in to your account using SSH.
-
Change the directory to where you want to use the PHPMailer project. The location can be the document root of a domain as shown, or a subdirectory:
-
To install PHPMailer, type the following command:
Testing the PHPMailer installation
To test the installation, follow these steps:-
Create a PHP file to test the installation. You can create the file with the editor of your choice. In this procedure we use vi, but you can also use other command line editors or the graphical editor in your control panel. The file is named mailer.php in this example, but it can be any name ending in .php.
-
Type (or paste) the following code into the editor. Replace the email addresses and password with the actual values for your account and save the file:
-
Test the setup by running the file from the command line or visiting the page in your web browser. The command line is shown below.