Set max size (in MB) for attachment

I would like to set a maximum size for attachments in messages and offers (e.g.: < 4 MB).
How to do?

The file upload limit is set on the WordPress level for all the attachments; please follow these instructions to change it How to Increase the Max Upload Size in WordPress