Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

[Bug] WooCommerce attachment emails fail on Azure App Service — ABSPATH resolves incorrectly in containerized WordPress (v1.2.1)

未关闭 适合新手
#219 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
72/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
冷清
技术栈
azure, php, wordpress
领域
backend, cloud

调研方向

从 admin/mailer/class-azure_app_service_email-controller.php 开始,检查 generate_request_body(),然后使用所列出的 WordPress 和 WooCommerce 配置,在 Azure App Service 容器中复现带附件的电子邮件失败问题。完成的标准是:带有发票 PDF 附件的订单通知电子邮件能够成功送达,同时不带附件的电子邮件继续正常工作。

由索引模型根据 Issue 内容生成。

描述

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

  1. Deploy WordPress on Azure App Service (Linux, containerized)
  2. Install WooCommerce and the App Service Email plugin v1.2.1
  3. Place a test order
  4. Observe that the New Order and Processing Order emails never arrive
  5. 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.

主要语言
HCL
星标
139
派生
84
PR 合并指标
30 天内没有已合并 PR

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

Azure/wordpress-linux-appservice 的其他 Issue

查看 Azure/wordpress-linux-appservice 的全部 Issue

相似的 Issue

更多 Backend & API Design Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。