Order confirmation with attachment I'm sending order confirmation messages via the module message-notify. As mail system i'm using MimeMail.
Is there a possibility to add an attachment to the email with the key: commerce_order_order_confirmation?

I tried to add the attachment in hook_mail()

function mymodule_mail($key, &amp;$message, $params) {

    if(isset($key)) {
        if($key == 'commerce_order_order_confirmation') {
            $attachment = array(
                'filecontent' =&gt; file_get_contents(DRUPAL_ROOT . '/sites/default/files/pdf/myattachment.pdf'),
                'filename' =&gt; 'myattachment.pdf',
                'filemime' =&gt; 'application/pdf',
            );

            $message['params']['attachments'][] = $attachment;
        }
    }
}
You want to change the email before it is sent.
So try this as a starting point (put together with the help of:
1. your post
2. https://drupal.stackexchange.com/a/98559/34326
3. https://www.drupal.org/node/2057703#comment-8343071):

function mymodule_mail_alter(&amp;$message) {


    if ($message['id'] == 'message_notify_commerce_order_order_confirmation') {
        $file = file_create_url(file_build_uri('path-to-file-relative-to-your-files-folder.pdf'));
        $attachment = array(
            'filecontent' =&gt; file_get_contents($file),
            'filename' =&gt; 'test.pdf',
            'filemime' =&gt; 'application/pdf',
        );

        $message['params']['attachments'][] = $attachment;
    }
}


The file should be located in sites/default/files or whatever applies to your site.
You should also change filemime to what matches your file.

I am getting errors "realpath() expects parameter 1 to be a valid path" and "is_file() expects parameter 1 to be a valid path", but the email with the attachment is sent anyway, which is why I am posting this.The errors seem to be related to the 'filepath' parameter which is mentioned in the 3rd link, because depending on what I define, the results vary:
eg. 'filepath' =&gt; $file,, which gives me no attachment and no error or 'filepath' =&gt; $file-&gt;uri,, which gives me an additional error about a "non-object" and no attachment.

http://passivemanagement.net/blog/2014/01/let-drupal-send-email-attachment-using-mimemail-module uses a different markup for the file, but right now I can't figure out, how to adapt it to the task at hand.