Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

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

オープン 初心者向け
#219 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
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. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

Azure/wordpress-linux-appservice のほかの issue

Azure/wordpress-linux-appservice の issue をすべて見る

似ている issue

Backend & API Design の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。