PHPMailer – an open-source library for sending emails. Today it is one of the most popular ways to send emails for PHP developers.
Why use PHPMailer?
The simple mail relies on the server email subsystem to work and when you want to change some settings like the SMTP server or the authentication parameters, you need to do it system-wide.
Unless you’re not the owner of a dedicated server or use the local PHP development environment, this process can be quite complicated and you probably won’t even have permission for this operation. The simultaneous use of different configurations, for example, the use of multiple SMTP accounts and programmatically switching between them, is also almost impossible.
PHPMailer makes it easy to change any parameter dynamically right in your PHP script.
The next reason to use PHPMailer is that it can provide some advanced functionality that simple mail doesn’t. Mail can be useful for sending simple text emails, but it’s very limiting if you need to add attachments or send HTML emails, while with PHPMailer it’s much easier.
Additional advantages are: