我已经构建了一个 cakePHP3 应用程序,我正在寻找有关以下情况的一些建议。电子邮件配置设置如下,以便在创建新订单时发送邮件。
public function orderCreated($order, array $attachments = [])
{
$email = $this
->locale($order->customer->language)
->to($order->customer->email)
->from(Configure::read('Webshop.email'), Configure::read('Webshop.name'))
->subject(__('Confirmation of your order {0}', $order->nr))
->template('orders' . DS . 'order_created')
->set(['order' => $order])
->attachments($attachments);
return $email;
}
多年来一直运行良好,但我想为这封特定的电子邮件(和其他电子邮件)添加一些新功能。如果他们愿意,管理员应该能够覆盖 orders/order_created.ctp 模板的内容,这样他们就可以自己定义这封电子邮件的内容。所以他们不必依赖我提供的 order_created.ctp 模板中的相同内容。
创建用于保存他们自己的电子邮件的 UI 不是问题。但是我真的不知道如何将覆盖的内容提供给 cakePHP3 邮件程序。我试过设置
->template(false)
->message($new_content)
但这没有帮助。邮件未到达邮箱,因为正文为空。
谢谢。