Skip to content

Attached assets for email notifications are silently dropped over 15 mb #2697

@MoritzLost

Description

@MoritzLost

Describe the bug

Our client reported an issue that they have attached an asset to an email notification, but the attachment isn't sent with the email.

I found that Formie has a hardcoded limit for attachments at 15 mb:

// Check if the asset it over 15mb (a reasonable threshold)
if (($asset->size / 1000000) > 15) {
    Formie::info('Not attaching “' . $asset->filename . '” due to large file size: ' . $asset->size . '.');

    continue;
}

Looks like the attachment is just silently dropped if the attachment is larger than the specified size.

I can understand the intention – a lot of email servers will reject emails with large attachment. However, the implementation needs some work.

Some suggestions:

  • Make this limit configurable, so we can specify the maximum allowed attachment size.
  • Enforce the limit (whether it's the current or the newly configurable limit) in the interface. If the selected asset is above the limit, prevent the notification from saving and show an actionable error message.
  • Provide alternatives for large attachments – for example, have an option to just inject a link to the selected assets into the email?

Steps to reproduce

  1. In any form, open the Email Notifications tab and create a notification.
  2. In the notification, open the Advanced tab and select an asset with a size over 15 mb under Attach Assets.

Form settings

N/A

Craft CMS version

5.8.22

Plugin version

3.1.18

Multi-site?

No

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions