# How do I add attachments to a mailable?

You can attach files to a mailable by using the `whenSendingAsMail` callback:

```php
\Aero\Cart\Events\OrderConfirmation::whenSendingAsMail(function (\Aero\Events\Actions\Mailable $mailable, \Aero\Cart\Events\OrderConfirmation $event) {
    $pdf = \Aerocargo\PdfInvoices\Invoice::forOrder($event->order, 'invoice');

    $mailable->attachData(
        $pdf->output(),
        "{$event->order->reference}-invoice.pdf",
        [
            'mime' => 'application/pdf',
        ]
    );
});
```

<p class="callout info">This example uses the [`aerocargo/pdf-invoice`](https://agora.aerocommerce.com/packages/aerocargo/pdf-invoices) module to generate a PDF Invoice for the order.</p>