Security, Secrets & Attachments
WireMailPHPMailer is hardened for production ProcessWire sites where module configuration screens, error logs, and dynamic attachment paths represent real attack surfaces.
1. Write-Only Masked Secrets
Section titled “1. Write-Only Masked Secrets”In WireMailPHPMailerConfig, six sensitive configuration fields are strictly write-only:
dsn(rendered astype="password")PasswordOAuthClientSecretOAuthRefreshTokenDKIM_passphraseDKIM_private_string
Before Inputfield::render, existing values are masked so credentials never leak back into browser HTML. Submitting the config form with blank password fields preserves the stored secrets unless you explicitly check them in _clear_secrets.
2. DSN Validation & Log Credential Redaction
Section titled “2. DSN Validation & Log Credential Redaction”- The
dsnfield accepts onlysmtp://andsmtps://schemes with an allowlisted set of query parameters. - Call
WireMailPHPMailer::redactDsnCredentials($text)before writing SMTP errors or diagnostics to logs; it scrubssmtp://andsmtps://userinfo credentials (including email-shaped usernames) automatically. Debugoutputdefaults to'error_log'rather than echoing raw SMTP transcripts to browser output.
3. Hardened Local Attachment Validation
Section titled “3. Hardened Local Attachment Validation”$mail->attachment($value, $filename = '') enforces strict filesystem rules before attaching any file:
- Rejects PHP stream wrappers (
php://,phar://,http://,ftp://). - Rejects null bytes (
\0),..parent traversal segments, and symbolic links (is_link()). - Explicitly blocks ProcessWire configuration files (
site/config*.php) from ever being attached to an email.
4. ProcessWire Demo Mode ($config->demo)
Section titled “4. ProcessWire Demo Mode ($config->demo)”When $config->demo is enabled, WireMailPHPMailer automatically blocks both ___send() (returning 0) and the admin _test_email test sender so demo environments can never be abused as mail relays.