A robust, modern integration of the popular PHPMailer library for the ProcessWire CMS/CMF. This module transparently extends the core WireMail class, allowing you to use advanced mailing features via familiar API calls, or access the native PHPMailer instance directly for fine-grained control.
- ProcessWire:
3.0.0or newer - PHP:
8.0or newer (Strict Types enforced)
- Copy the module files into your
site/modules/WireMailPHPMailer/directory. - In the ProcessWire admin, go to Modules > Refresh.
- Locate WireMailPHPMailer under the WireMail section and click Install.
- Configure your SMTP, Sendmail, or PHP Mail settings directly via the module's configuration screen.
(Note: The module comes pre-packaged with the PHPMailer library in the vendor directory. You do not need to run Composer manually unless you are doing custom developmental modifications.)
You can use the module through the standard ProcessWire WireMail API or access the underlying PHPMailer instance directly.
This approach seamlessly integrates into existing ProcessWire core API workflows.
$mail = wire('modules')->get('WireMailPHPMailer');
$mail->from('from@example.com')
->fromName('Sender Name')
->to('to@example.com')
->subject('Your Subject Here')
->body('This is the plain-text message body.')
->bodyHTML('<h1>This is the HTML message body</h1>')
->send();If you need advanced configuration, attachments, or specific PHPMailer features, you can interact with the instance directly.
/** @var WireMailPHPMailer $wireMail */
$wireMail = wire('modules')->get('WireMailPHPMailer');
// Retrieve the initialized PHPMailer instance
// (passing `false` skips loading the module configurations if needed)
$mail = $wireMail->getInstance();
$mail->addAddress('email@domain.ltd', 'Recipient Name');
$mail->isHTML(true);
$mail->Subject = 'Advanced PHPMailer Usage';
$mail->Body = '<h1>Hello World</h1><p>ProcessWire + PHPMailer</p>';
$mail->AltBody = 'Hello World - ProcessWire + PHPMailer';
if ($mail->send()) {
echo "Message has been sent.";
} else {
echo "Message could not be sent. Mailer Error: " . $mail->ErrorInfo;
}The module provides an extensive settings page in the ProcessWire admin (Modules > Configure > WireMailPHPMailer) where you can define:
- Transport method: SMTP, Sendmail, or native
mail() - SMTP credentials: Host, Port, Username, Password, AutoTLS (enabled by default)
- Encryption: SSL / TLS
- Authentication Types: LOGIN, PLAIN, CRAM-MD5, and native XOAUTH2 support.
- DKIM Signing: Domain, Identity, Selector, Path to Private Key
- Global Defaults: Default Sender (
From/FromName), Reply-To, and Bcc tracking.
WireMailPHPMailer supports natively injecting XOAUTH2 authentication directly into ProcessWire's unified WireMail flow via the underlying PHPMailer engine.
Because OAuth2 providers are heavy, this module allows you to selectively install the right provider package to the root workspace using Composer, keeping the module core lightweight.
From your ProcessWire project root (where the main composer.json is located), require the provider:
- For Google:
composer require league/oauth2-google - For Yahoo:
composer require hayageek/oauth2-yahoo - For Microsoft:
composer require stevenmaguire/oauth2-microsoft - For Azure:
composer require greew/oauth2-azure-provider
- Go to Modules > Configure > WireMailPHPMailer.
- Select XOAUTH2 under
Auth Type. - Fill out the OAuth2 Settings block that appears below it:
- Select the OAuth Provider (Google, Yahoo, Microsoft, or Azure).
- Enter your OAuth Email (the account initiating sending).
- Provide your Client ID and Client Secret.
- (Azure Only) Specify your Tenant ID (or leave default
common).
- Save the module settings.
After saving your Client ID and Client Secret, an Authorize via {Provider} button will appear in the settings.
- Click the authorization button.
- Follow the prompt to consent and log into your provider account.
- You will be redirected back securely to the module's setup page, where the module automatically pulls and saves your Refresh Token.
That's it! WireMailPHPMailer will intercept ProcessWire's Mail sends and handle token refreshes in the background natively.
This module is free and open-source software.