PHPMailer is a PHP library for building and sending email with attachments, HTML bodies, and SMTP authentication. It is widely embedded in CMS and application codebases.
Overview
PHPMailer helps PHP applications send mail without relying on the bare mail() function, which the authors describe as awkward for authentication, HTML, attachments, and correct encoding. The class handles multipart messages, address lists, inline images, and several content encodings, including UTF-8 when servers support SMTPUTF8.
An integrated SMTP client can deliver mail on platforms that lack a local mail transfer agent, such as typical Windows setups. Supported transports include SMTPS and STARTTLS, with LOGIN, PLAIN, CRAM-MD5, and XOAUTH2 authentication. Optional DKIM and S/MIME signing are available for message integrity and security workflows.
The package validates addresses, guards against header injection, localizes error strings, and ships with Composer packaging for standard PHP projects. Documentation, examples, and generated API references cover common providers and patterns like mailing lists and contact forms.
Major PHP content systems and frameworks have adopted PHPMailer for outbound mail. The maintainers recommend Composer installation and note compatibility with supported PHP releases above 5.5.
Key features
- SMTP sending without a local mail server
- HTML and multipart messages
- Attachments and inline images
- Multiple recipients and reply-to
- OAuth2 and classic SMTP auth
- DKIM and S/MIME signing
- UTF-8 and encoding options
- Localized error messages
Use cases
- Transactional email from PHP apps
- Contact and notification forms
- HTML newsletters with attachments
- Cross-platform SMTP delivery
- Replacing raw mail() calls