Summary
On Azure App Service containerized WordPress deployments, WooCommerce order
notification emails that include attached invoice PDFs fail silently with the
following error in the Azure Email Logs:
Request body validation error. ContentBytes invalid. Should be base64
Basic emails (contact forms, password resets) send successfully. Only emails
with attachments are affected.
Root Cause
In admin/mailer/class-azure_app_service_email-controller.php, the
generate_request_body() method resolves attachment paths using ABSPATH:
foreach ($filePaths as $path) {
if ($path[0] !== '/') {
$path = ABSPATH . trim($path);
}
if (file_exists($path)) { ... }
}
On Azure App Service containerized WordPress, ABSPATH resolves to
/var/www/html while the actual running WordPress root is
/var/www/wordpress. The path resolves incorrectly, file_exists() returns
false, the attachment is silently dropped, and the ACS REST API rejects the
malformed request body.
The "ContentBytes invalid" error is a red herring — the real issue is a path
mismatch between ABSPATH and the actual WordPress root inside the container.
Steps to Reproduce
- Deploy WordPress on Azure App Service (Linux, containerized)
- Install WooCommerce and the App Service Email plugin v1.2.1
- Place a test order
- Observe that the New Order and Processing Order emails never arrive
- Check Azure Email Logs — error reads "ContentBytes invalid. Should be base64"
Expected Behavior
WooCommerce order notification emails send successfully with attached invoice
PDFs via Azure Communication Services.
Actual Behavior
Emails with attachments fail. Emails without attachments succeed.
Proposed Fix
Replace ABSPATH with a path derived from WP_CONTENT_DIR, which correctly
resolves to the active WordPress root regardless of container layout. Also
adds an empty path guard and immediate trim to prevent related edge case
failures:
foreach ($filePaths as $path) {
$path = trim($path);
if (empty($path)) { continue; }
if ($path[0] !== '/') {
$wp_root = rtrim(str_replace('wp-content', '', WP_CONTENT_DIR), '/');
$path = $wp_root . '/' . $path;
}
if (file_exists($path)) { ... }
}
A community fix including a PowerShell automation script and full root cause
analysis is documented here:
https://github.com/JONeillSr/Repair-AppServiceEmailAttachmentPatch
Environment
| Component |
Version |
| App Service Email Plugin |
v1.2.1 |
| WordPress |
7.x |
| WooCommerce |
8.x+ |
| Azure App Service |
Linux, containerized |
| PHP |
8.x |
Workaround
Apply the patch manually via SSH or using the PowerShell automation script
linked above. The fix is confirmed working in production.
Summary
On Azure App Service containerized WordPress deployments, WooCommerce order
notification emails that include attached invoice PDFs fail silently with the
following error in the Azure Email Logs:
Basic emails (contact forms, password resets) send successfully. Only emails
with attachments are affected.
Root Cause
In
admin/mailer/class-azure_app_service_email-controller.php, thegenerate_request_body()method resolves attachment paths usingABSPATH:On Azure App Service containerized WordPress,
ABSPATHresolves to/var/www/htmlwhile the actual running WordPress root is/var/www/wordpress. The path resolves incorrectly,file_exists()returnsfalse, the attachment is silently dropped, and the ACS REST API rejects the
malformed request body.
The "ContentBytes invalid" error is a red herring — the real issue is a path
mismatch between ABSPATH and the actual WordPress root inside the container.
Steps to Reproduce
Expected Behavior
WooCommerce order notification emails send successfully with attached invoice
PDFs via Azure Communication Services.
Actual Behavior
Emails with attachments fail. Emails without attachments succeed.
Proposed Fix
Replace
ABSPATHwith a path derived fromWP_CONTENT_DIR, which correctlyresolves to the active WordPress root regardless of container layout. Also
adds an empty path guard and immediate trim to prevent related edge case
failures:
A community fix including a PowerShell automation script and full root cause
analysis is documented here:
https://github.com/JONeillSr/Repair-AppServiceEmailAttachmentPatch
Environment
Workaround
Apply the patch manually via SSH or using the PowerShell automation script
linked above. The fix is confirmed working in production.