Files are attached when calling from code: the reserved attachments key in $data is a list of paths on the server. It does not become a placeholder.
$modx->services->get('Vestnik')->trigger('shop.order.new', [
'email' => $order->get('email'),
'order_id' => $order->get('id'),
'attachments' => [
MODX_CORE_PATH . 'components/vestnik/attachments/invoice-105.pdf', // path
['file' => MODX_CORE_PATH . 'components/vestnik/attachments/terms.pdf', 'name' => 'Terms.pdf'], // path + name in the email
],
], 'component');
- The queue stores the path, not the contents: the file must exist when cron sends the email.
- Only files from the
vestnik_attachments_pathfolder can be attached (empty —core/components/vestnik/attachments/). The MODX configuration, PHP files and hidden files can never be attached. - A file outside the folder or a missing file is a sending error; the email goes to retries and the reason is shown in the queue and log.
- Attachments are added to every email of this
trigger()call. - The
vestnik_notifysnippet does not pass attachments.