1. Home
  2. Languages
  3. How to Install PHP Libraries

How to Install PHP Libraries

Introduction

This article explains how to send emails with a PHP application using PHPMailer. Before doing so, however, you must use Composer to download PHPMailer and automatically create an autoloader file.

Users often do not know how to proceed, hence this article.

Note:The Glossary contains explanations on multiple topics and can be consulted to clarify certain terms.

Step 1: Installation of Composer

Please refer to the article How to Install Composer.

Step 2: Installation of PHPMailer

Make sure that you have installed Composer and that you are still connected via SSH, as explained before.

  1. Create the desired folder for PHPMailer:

mkdir mail_app

  1. Move to the active current working directory (CWD):

cd mail_app

  1. Install PHPMailer with the Composer command:

composer require phpmailer/phpmailer

  1. Here is the output of Composer for the installation of php_mailer:
  1. Here, there is nothing to reload normally. It is in the script that we must indicate the path to PHPMailer:

/home/user/mail_app/vendor/phpmailer/phpmailer

Updated on June 4, 2026

Related Articles