How to install phpMailer in a shared hosting environment?

To install the PHPMailer download its source files and include the required files manually:


1. On the PHPMailer homepage download the ZIP file with the source code;

2. On the right click on the “Clone or download”;

3. Select the “Download ZIP” option;

4. Unzip the package placing them to the directory in which you want to save the source files.


Then add the necessary classes in your PHP script.


It is important to include the main PHPMailer classes; the Exception class (to handle errors) and the SMTP class, in case if you’ll connect to an SMTP server to deliver mail. 


You need also to set the namespace. 


This is how your PHP script will look like, if your source code directory is “C:\PHPMailer”:


<?php use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\Exception; /* Exception class. */ require 'C:\PHPMailer\src\Exception.php'; /* The main PHPMailer class. */ require 'C:\PHPMailer\src\PHPMailer.php'; /* SMTP class, needed if you want to use SMTP. */ require 'C:\PHPMailer\src\SMTP.php'; $email = new PHPMailer(TRUE); /* ... */
Coupon partner