PHPMailer
The classic full-featured email creation and sending library for PHP
Repository Health
Technical Analysis
PHPMailer is a long-running PHP library for composing and sending email, supporting SMTP (with authentication and TLS/SSL), the local sendmail binary, or PHP’s built-in mail() function as interchangeable transports. It handles the parts of email that are easy to get wrong by hand: MIME multipart message construction, attachments (including inline images), HTML email with automatic plain-text alternative generation, character-set and encoding handling, and DKIM signing.
The core classes (PHPMailer, SMTP, POP3, Exception, OAuth) live under src/ with no required external dependencies for the base library, though optional Composer packages add OAuth2 authentication (Gmail, Outlook) and other SMTP providers. It has been a foundational dependency for a large share of the PHP ecosystem — including WordPress’s core mail functions — for over two decades.
What You Get
- A unified
PHPMailerclass supporting SMTP (with auth and TLS/STARTTLS), localsendmail, or PHP’smail()as interchangeable send methods - Automatic MIME multipart message construction, including file attachments, inline/embedded images, and HTML email with an auto-generated plain-text alternative
- Built-in
SMTPandPOP3classes for lower-level protocol interaction when the high-level API isn’t enough - OAuth2 authentication support (via the companion
OAuthclass) for Gmail, Outlook, and other providers requiring modern auth instead of plain SMTP credentials - Multi-language error message support (
language/directory) covering dozens of locales - DKIM signing support for improving email deliverability and reducing spam-folder placement
Common Use Cases
- Sending transactional emails (password resets, order confirmations, notifications) from a PHP application via a real SMTP relay instead of PHP’s unreliable mail()
- Sending HTML marketing or newsletter-style emails with inline images and file attachments from a self-hosted PHP app
- Authenticating against Gmail/Outlook SMTP with OAuth2 instead of storing a plaintext app password
- Powering the email layer of a CMS or framework plugin (PHPMailer is the library WordPress core itself uses for outgoing mail)
Under The Hood
Architecture - The library is organized as a small set of focused classes under src/: PHPMailer.php is the main facade handling message composition and orchestrating the send; SMTP.php implements the SMTP protocol directly (commands, response parsing, TLS negotiation) rather than delegating to a third-party SMTP client; POP3.php supports POP-before-SMTP authentication for legacy mail servers; OAuth.php/OAuthTokenProvider.php implement OAuth2 token handling for providers like Gmail and Outlook; and DSNConfigurator.php parses connection-string style configuration. This is a deliberately dependency-light design — the base library needs no external packages to send mail. Tech Stack - Pure PHP with a Composer manifest (composer.json) defining the package as a library type; PHPCS (phpcs.xml.dist) enforces coding standards, PHPUnit (phpunit.xml.dist) drives the test suite, and phpDocumentor (phpdoc.dist.xml) generates API docs. get_oauth_token.php is a standalone helper script for obtaining OAuth2 refresh tokens interactively. Code Quality - The test/ directory contains a substantial PHPUnit suite (PreSendTestCase.php plus dedicated fixtures for PHPMailer, SMTP, POP3, OAuth, and language tests), including fake SMTP/POP3 server shell scripts (fakesendmail.sh, fakepopserver.sh) so tests can exercise real protocol exchanges without a live mail server. The project maintains a SECURITY.md and UPGRADING.md, reflecting the operational discipline expected of a library embedded in millions of production codebases including WordPress core. API Design - Sending a basic email is a handful of property assignments ($mail->Host, $mail->addAddress(), $mail->Subject, $mail->Body) followed by a single $mail->send() call, with sensible defaults for encoding and MIME boundaries; the API predates PHP’s modern typed-property conventions but remains one of the most widely documented and copy-pasted email APIs in the PHP ecosystem.
Used by 8 apps in this directory
Appwrite
Developer Tools · Databases · Authentication
Open-source backend platform with Auth, Databases, Storage, Functions, Messaging, Realtime, and Sites — deploy via Docker or use Appwrite Cloud.
Hyvor Relay
Devops · AI Development · Monitoring
Self-hosted, open-source email API that automates DNS, manages SMTP delivery, and provides deep observability — replacing SES, Mailgun, and SendGrid with infrastructure you fully own.
Leantime
Productivity · Project Management · Collaboration
Project management built for ADHD, autism, and dyslexia — simple as Trello, powerful as Jira
LimeSurvey
Forms Surveys
The world's most flexible open-source survey platform with 900+ templates, conditional logic, 80+ languages, and full GDPR compliance for any scale.
matomo
Analytics
Open-source, privacy-first web and app analytics that puts you in complete control of your data.
Open Web Analytics
Analytics
Self-host your own Google Analytics alternative with heatmaps, session recordings, and full data ownership — no cloud required.
tirreno
Monitoring · Security
Embed security inside your product — detect threats, fraud, and abuse in real time at the application layer
Typemill
CMS
Open-source flat-file CMS for publishing Markdown-based documentation, manuals, and eBooks without a database.