PHPMailer

The classic full-featured email creation and sending library for PHP

Library
Composer
vv7.1.1
22,280stars
GNU LGPLv2.1

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
89/100Excellent
Development Activity84
Maintenance76
Community96
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
74/100Good
Architecture78
Code Quality82
Innovation55
Learning Curve80

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 PHPMailer class supporting SMTP (with auth and TLS/STARTTLS), local sendmail, or PHP’s mail() 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 SMTP and POP3 classes for lower-level protocol interaction when the high-level API isn’t enough
  • OAuth2 authentication support (via the companion OAuth class) 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

TypeScript
61%
BSD 3

Appwrite

Developer Tools · Databases · Authentication

57,057

Open-source backend platform with Auth, Databases, Storage, Functions, Messaging, Realtime, and Sites — deploy via Docker or use Appwrite Cloud.

View details
92
Repo Health
81
Technical
71
Dependency
Built with
TypeScript61%
PHP38%
Updated today
PHP
63%
AGPL 3.0

Hyvor Relay

Devops · AI Development · Monitoring

819

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.

View details
69
Repo Health
79
Technical
70
Dependency
Built with
PHP63%
Svelte23%
Go12%
Updated today
PHP
48%
AGPL 3.0

Leantime

Productivity · Project Management · Collaboration

11,391

Project management built for ADHD, autism, and dyslexia — simple as Trello, powerful as Jira

View details
90
Repo Health
68
Technical
67
Dependency
Built with
PHP48%
CSS20%
Blade17%
Updated 4 days ago
JavaScript
44%
Other

LimeSurvey

Forms Surveys

3,698

The world's most flexible open-source survey platform with 900+ templates, conditional logic, 80+ languages, and full GDPR compliance for any scale.

View details
86
Repo Health
62
Technical
62
Dependency
Built with
JavaScript44%
PHP34%
CSS12%
Updated today
PHP
79%
GPL 3.0

matomo

Analytics

21,786

Open-source, privacy-first web and app analytics that puts you in complete control of your data.

View details
95
Repo Health
82
Technical
62
Dependency
Built with
PHP79%
Updated today
PHP
80%
GPL 2.0

Open Web Analytics

Analytics

2,684

Self-host your own Google Analytics alternative with heatmaps, session recordings, and full data ownership — no cloud required.

View details
88
Repo Health
51
Technical
69
Dependency
Built with
PHP80%
JavaScript19%
Updated today
PHP
83%
AGPL 3.0

tirreno

Monitoring · Security

1,498

Embed security inside your product — detect threats, fraud, and abuse in real time at the application layer

View details
69
Repo Health
73
Technical
83
Dependency
Built with
PHP83%
Updated 5 days ago
JavaScript
52%
MIT

Typemill

CMS

612

Open-source flat-file CMS for publishing Markdown-based documentation, manuals, and eBooks without a database.

View details
85
Repo Health
57
Technical
69
Dependency
Built with
JavaScript52%
PHP38%
Updated 2 days ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search