Changing the maximum mail size in Postfix

Solution 1:

Add it anywhere in main.cf, it's not relevant :) But it's good to keep directives grouped in some logical manner, it is easier for maintance

According to official postfix documentation:
message_size_limit (default: 10240000) The maximal size in bytes of a message, including envelope information. Note: be careful when making changes. Excessively small values will result in the loss of non-delivery notifications, when a bounce message size exceeds the local or remote MTA's message size limit.

Additionally, the default mailbox size of 50M may prevent mail from being delivered, especially after increasing the permitted message size. To increase maximum per user mailbox size, add mailbox_size_limit = <size in bytes> to main.cf.

Additionally, as Ian Sparkes commented, if you are using a virtual mailbox configuration, you might need to set virtual_mailbox_limit = <size_in_bytes>.

Solution 2:

Yes, you are correct: message_size_limit is the configuration directive you need. Put it anywhere in the main.cf file and reload (or restart) Postfix.

You may use the postconf tool to check the currently configured value:

postconf message_size_limit

Solution 3:

Be careful if setting this limit to a high number. You need at least 1.5 times the size of message_size_limit of free space on the partition where the Postfix queue resides. If you don't have that free space, then all messages are rejected even if they are only a few kilobyte in size. And if you receive one message of this size and then the space exceeds (during final mailbox delivery) all further messages are rejected. Due to missing space.

Also note: Email is not a file transfer protocol. See this QA: Why do we still have such small email attachment filesize restrictions?


Solution 4:

Don't forget to set

virtual_mailbox_limit = <size_in_bytes>

if you are using a virtual mailbox configuration. Took me ages to find this, no one seems to talk about it. ;)