Suppose I have an assets field in my orders fields, how could I attach those files in the confirmation email?

1 Answer 1


I suppose you could use the \craft\commerce\services\Emails::EVENT_BEFORE_SEND_MAIL event for that.

use craft\commerce\events\MailEvent;
use craft\commerce\services\Emails;
use yii\base\Event;

    function (MailEvent $e) {
        // You would be able to access the `\craft\mail\Message` like so
        // $e->craftEmail;

        // And the `\craft\commerce\elements\Order` like so
        // $e->order

        // So adding an asset could be done by accessing the `attach` method.
        // https://www.yiiframework.com/extension/yiisoft/yii2-swiftmailer/doc/api/2.1/yii-swiftmailer-message#attach()-detail

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.