PHPMailer

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

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

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
88 /100 Excellent
Development Activity 84
Maintenance 72
Community 96
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
74 /100 Good
Architecture 78
Code Quality 82
Innovation 55
Learning Curve 80

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

PHP
93%
BSD 3

Appwrite

Authentication · Databases · Developer Tools

57,496

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

View details
94
Repo Health
81
Technical
65
Dependency
Built with
PHP 93%
Updated 5 days ago
PHP
63%
AGPL 3.0

Hyvor Relay

AI Development · Devops · Monitoring

908

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
68
Repo Health
79
Technical
70
Dependency
Built with
PHP 63%
Svelte 23%
Go 11%
Updated 1 weeks ago
PHP
48%
AGPL 3.0

Leantime

Collaboration · Productivity · Project Management

11,672

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

View details
90
Repo Health
68
Technical
65
Dependency
Built with
PHP 48%
CSS 20%
Blade 17%
Updated 1 weeks ago
JavaScript
43%
Other

LimeSurvey

Forms Surveys

3,736

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
63
Dependency
Built with
JavaScript 43%
PHP 35%
CSS 12%
Updated 5 days ago
PHP
78%
GPL 3.0

matomo

Analytics

21,905

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
PHP 78%
Updated 4 days ago
PHP
75%
GPL 2.0

Open Web Analytics

Analytics

2,687

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
70
Dependency
Built with
PHP 75%
JavaScript 22%
Updated 4 days ago
PHP
83%
AGPL 3.0

tirreno

Monitoring · Security

1,530

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

View details
74
Repo Health
73
Technical
82
Dependency
Built with
PHP 83%
Updated 5 days ago
JavaScript
51%
MIT

Typemill

CMS

619

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

View details
84
Repo Health
57
Technical
69
Dependency
Built with
JavaScript 51%
PHP 39%
Updated 1 weeks 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