2026年5月20日
2026年5月20日
WooCommerceの注文確認メールが届かない場合の解決方法
はじめに
WooCommerceで注文完了後に確認メールが届かない場合、WordPressのデフォルトメール(wp_mail)がスパム判定されているか、SMTPが設定されていないことが主な原因です。
症状・原因
- 注文完了後に顧客・管理者ともメールが届かない
- 迷惑メールフォルダに入っている
- 一部のメールアドレスには届くが特定のドメインには届かない
- WooCommerce のメール設定で送信先が間違っている
解決手順
ステップ1:WooCommerceのメール設定を確認する
WooCommerce → 設定 → メール
- 送信元メールアドレス: info@example.com(実在するアドレス)
- 送信元名: サイト名
- 各メールタイプの有効化を確認
- 新規注文(管理者へ): 有効
- 注文処理中(顧客へ): 有効
- 注文完了(顧客へ): 有効
ステップ2:テストメールを送信する
# WP-CLIでテストメールを送信
wp eval "wp_mail('test@example.com', 'WooCommerceテスト', 'メール送信テスト');"
# WooCommerceのメールをトリガーするテスト注文を作成
wp wc order create --status=processing --user=admin
管理画面から:WooCommerce → 設定 → メール → 各メールの「テンプレートをプレビュー」
ステップ3:SMTPプラグインを設定する
# FluentSMTPをインストール(完全無料)
wp plugin install fluent-smtp --activate
FluentSMTP設定例(SendGrid使用):
管理画面 → FluentSMTP → Settings → Add New Connection
- From Email: noreply@example.com
- From Name: サイト名
- Provider: SendGrid
- API Key: SG.xxxxxxxxxx(SendGridのAPIキー)
ステップ4:phpmailer_initでSMTPを直接設定する
// functions.php — SMTP設定(SMTPプラグインなし)
add_action('phpmailer_init', function(PHPMailer\PHPMailer\PHPMailer $phpmailer) {
$phpmailer->isSMTP();
$phpmailer->Host = 'smtp.sendgrid.net';
$phpmailer->Port = 587;
$phpmailer->SMTPAuth = true;
$phpmailer->SMTPSecure = 'tls';
$phpmailer->Username = 'apikey'; // SendGridは固定
$phpmailer->Password = defined('SENDGRID_API_KEY') ? SENDGRID_API_KEY : '';
$phpmailer->From = 'noreply@example.com';
$phpmailer->FromName = get_bloginfo('name');
});
ステップ5:WooCommerceのメールフックをカスタマイズする
// functions.php — 注文完了メールに追加情報を付加
add_filter('woocommerce_email_subject_customer_completed_order', function($subject, $order) {
return sprintf('[%s] ご注文番号 #%s が完了しました', get_bloginfo('name'), $order->get_order_number());
}, 10, 2);
// 送信失敗をログに記録
add_action('wp_mail_failed', function(WP_Error $error) {
error_log('WooCommerce mail failed: ' . $error->get_error_message());
});
注意事項
- WordPress標準の
wp_mail(PHPMailのmail()関数)はスパム判定されやすいため、本番環境ではSMTPプラグインの使用を強く推奨します - 送信元メールアドレスはサイトのドメインと同じドメインのアドレスを使用してください(
info@example.comなど) - SPF・DKIM・DMARCの設定でメール到達率が大幅に改善します
まとめ
WooCommerceのメール未達は多くの場合SMTPの未設定が原因です。FluentSMTPやSendGridを使ってSMTP送信を設定し、wp_mail_failed フックでエラーをログに記録することで原因特定と再発防止ができます。