Steps to reproduce
Describe the bug
A TypeError occurs during DKIM validation in Nextcloud Mail. The PHPMailer DKIMValidator crashes because it receives a null value for the canonicalization $style argument, which is expected to be a string. This issue is particularly prevalent in environments running PHP 8.2+ where type hinting is strictly enforced.
Steps to reproduce
Use Nextcloud Mail in an environment running PHP 8.2 or 8.3 (e.g., Debian 13 based Docker containers).
Receive or view an email that triggers the internal DKIM validation logic.
The app fails to render the mail or throws a 500 error, and the following entry appears in the Nextcloud logs.
Nextcloud version: (32.0.3)
Mail app version: 5.6.5
PHP version: 8.2 / 8.3 (Debian 13 Docker environment) Nextcloud-fpm image
Database: MySQL/MariaDB
MTA: Postfix + Rspamd (External validation confirms DKIM signatures are valid)
Expected behavior
Expected behavior
The DKIM validator should gracefully handle cases where the canonicalization style cannot be determined, or provide a default string value (e.g., 'simple' or 'relaxed') to avoid a fatal TypeError.
Actual behavior
The application logs a fatal error:
PHPMailer\DKIMValidator\DKIM::canonicalizeBody(): Argument #2 ($style) must be of type string, null given, called in /var/www/html/custom_apps/mail/vendor/phpmailer/dkimvalidator/src/Validator.php on line 102
Environment information
Actual behavior
TypeError: PHPMailer\DKIMValidator\DKIM::canonicalizeBody(): Argument #2 ($style) must be of type string, null given, called in /var/www/html/custom_apps/mail/vendor/phpmailer/dkimvalidator/src/Validator.php on line 102 in file '/var/www/html/custom_apps/mail/vendor/phpmailer/dkimvalidator/src/DKIM.php' line 127
Mail app version
5.6.5
Nextcloud version
32.0.3
Mailserver or service
postfix + dovecot + rspamd
Operating system
nextcloud-fpm image
PHP engine version
PHP 8.3
Nextcloud memory caching
apcu redis
Web server
Apache (supported)
Database
MariaDB
Additional info
Additional context
External testers (like Mail-Tester/Mecasa) confirm the DKIM signatures on the processed emails are technically correct and valid. The issue seems isolated to the internal PHP-based parsing of the message body during the validation phase within the Mail app. Disabling dkim-validation via OCC resolves the crash, confirming the source of the error.
Update: I've also identified an Undefined array key 1 error at Validator.php#87. This happens when the DKIM c= tag contains only a single value (e.g., c=relaxed instead of c=relaxed/relaxed). The code assumes a split will always yield two elements, leading to a null value being passed to canonicalizeBody(), which triggers the subsequent TypeError.
Steps to reproduce
Describe the bug
A TypeError occurs during DKIM validation in Nextcloud Mail. The PHPMailer DKIMValidator crashes because it receives a null value for the canonicalization $style argument, which is expected to be a string. This issue is particularly prevalent in environments running PHP 8.2+ where type hinting is strictly enforced.
Steps to reproduce
Use Nextcloud Mail in an environment running PHP 8.2 or 8.3 (e.g., Debian 13 based Docker containers).
Receive or view an email that triggers the internal DKIM validation logic.
The app fails to render the mail or throws a 500 error, and the following entry appears in the Nextcloud logs.
Nextcloud version: (32.0.3)
Mail app version: 5.6.5
PHP version: 8.2 / 8.3 (Debian 13 Docker environment) Nextcloud-fpm image
Database: MySQL/MariaDB
MTA: Postfix + Rspamd (External validation confirms DKIM signatures are valid)
Expected behavior
Expected behavior
The DKIM validator should gracefully handle cases where the canonicalization style cannot be determined, or provide a default string value (e.g., 'simple' or 'relaxed') to avoid a fatal TypeError.
Actual behavior
The application logs a fatal error:
Environment information
Actual behavior
Mail app version
5.6.5
Nextcloud version
32.0.3
Mailserver or service
postfix + dovecot + rspamd
Operating system
nextcloud-fpm image
PHP engine version
PHP 8.3
Nextcloud memory caching
apcu redis
Web server
Apache (supported)
Database
MariaDB
Additional info
Additional context
External testers (like Mail-Tester/Mecasa) confirm the DKIM signatures on the processed emails are technically correct and valid. The issue seems isolated to the internal PHP-based parsing of the message body during the validation phase within the Mail app. Disabling dkim-validation via OCC resolves the crash, confirming the source of the error.
Update: I've also identified an Undefined array key 1 error at Validator.php#87. This happens when the DKIM c= tag contains only a single value (e.g., c=relaxed instead of c=relaxed/relaxed). The code assumes a split will always yield two elements, leading to a null value being passed to canonicalizeBody(), which triggers the subsequent TypeError.