You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

OpenCart报错求助:PHP致命错误提示需指定收件人邮箱

Fixing OpenCart's "Error: E-Mail to required!" Fatal Error

Let's break down this issue and work through solutions step by step. First, let's anchor on the core error from your stack trace:

PHP Fatal error: Uncaught exception 'Exception' with message 'Error: E-Mail to required!' in /home/projects/public_html/system/storage/modification/system/library/mail.php:94

This error fires because OpenCart's mail class tries to send an email without a valid recipient address set. The stack trace shows this happens when the addOrderHistory method (for order #145031, status ID 2440) calls Mail->send().

Common Causes & Fixes

1. Empty Customer Email for Order #145031

The most probable issue is that the target order has no associated customer email address.

How to verify:

  • Check the order in your OpenCart admin: Navigate to Sales > Orders, find order 145031, and inspect the customer's email field.
  • Or run a quick database query (replace oc_ with your actual table prefix if needed):
    SELECT email FROM oc_order WHERE order_id = 145031;
    

Fix:

  • If the email is empty, manually update it via the admin panel or SQL.
  • To prevent future errors, add a validation check before sending emails in the order history code:
    // In your modified order model file (vq2-system_storage_modification_catalog_model_checkout_order.php)
    $order_info = $this->getOrder($order_id);
    if (!empty($order_info['email'])) {
        $mail->setTo($order_info['email']);
        // Rest of your mail setup (subject, content, etc.)
        $mail->send();
    } else {
        // Optional: Send a alert to your admin instead
        $mail->setTo($this->config->get('config_email'));
        $mail->setSubject('Missing Customer Email for Order #' . $order_id);
        $mail->setText('Order #' . $order_id . ' has no customer email attached. Please review it immediately.');
        $mail->send();
    }
    

2. VQMod Modification Broke Recipient Setup

Since your code uses VQCache files, a third-party modification may have removed or corrupted the code that sets the email recipient.

How to verify:

  • Open vq2-system_storage_modification_catalog_model_checkout_order.php and go to line 1619 (where Mail->send() is called). Look for code like $mail->setTo($order_info['email']); right before the send call. If this line is missing, or $order_info['email'] is being overwritten, that's the problem.

Fix:

  • Compare the modified code with the original OpenCart catalog/model/checkout/order.php file to restore the missing recipient setup logic.
  • Disable recently installed VQMod plugins related to order emails, test if the error resolves, then debug the problematic plugin's code.

3. Mail Class Validation Edge Case

Less likely, but worth checking: the mail class may be overly strict about recipient validation.

How to verify:

  • Open /home/projects/public_html/system/storage/modification/system/library/mail.php and look at line 94. The exception is thrown here when the to array is empty.
  • Confirm that every call to $mail->send() is preceded by a valid $mail->setTo() call with a non-empty email.

Fix:

  • Add a safety check directly in the mail class (note: modifying core files isn't ideal, so prioritize fixing the calling code first):
    // In mail.php, right before throwing the exception
    if (empty($this->to)) {
        // Fallback to admin email
        $this->setTo($this->config->get('config_email'));
        // Log the issue for debugging
        $this->log->write('Attempted to send email without recipient. Triggered by order ID: ' . $order_id);
    }
    

内容的提问来源于stack exchange,提问作者Frank Turtle

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 07:47:03