What it is
PHPMailer is an open source library for sending email from PHP. It builds properly formed messages with HTML and plain-text bodies, attachments, embedded images, and multiple recipients, copies and blind copies. It also handles character encoding and the line formatting rules that mail servers expect, which are easy to get wrong by hand. It is one of the most widely used PHP libraries.
Its main strength is sending through an SMTP server with authentication and encryption, rather than relying on PHP's basic mail function. That makes it easy to point an application at a mail service such as Amazon SES and keep delivery, signing and bounce handling with the provider. It is installed with Composer.
How I use it
- Rental Pilot's PHP API sends mail with PHPMailer through Amazon SES.
- Delivery and return emails reach the site contacts automatically.
- Sits beside mPDF, which generates the invoices and agreements that go out as documents.
PHPMailer is the right tool when a PHP application needs to send real email through a proper mail service, with attachments and HTML, without writing the message format by hand. I reach for it because Rental Pilot sends business email that customers act on, so it has to go through a reputable sender like SES.
Questions
How does Rental Pilot send email?
The PHP API builds each message with PHPMailer and sends it through Amazon SES. Delivery and return emails go to the site contacts automatically.
Why not use PHP's built-in mail function?
It sends through the local server with little control. PHPMailer sends through a proper mail service over authenticated SMTP, with HTML and attachments handled correctly.