38

When sending large email to a new CentOS6 server running Postfix as the MTA, the following message is returned:

tried to deliver your message, but it was rejected by the recipient domain. We recommend contacting the other email provider for further information about the cause of this error. The error that the other server returned was: 552 552 5.3.4 Error: message file too big (state 18)

I found the following suggestion, but am unclear as to where it needs to be added in the main.cf file:

This was caused by Postfix and it's limit on not only messages but mailbox sizes.

I had to add this setting in /etc/postfix/main.cf:

message_size_limit = 31457280

How can the maximum mail size (including attachments) be increased in Postfix?

0

5 Answers 5

39

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>.

5
  • 3
    If you are using a virtual mailbox configuration, you might need to set virtual_mailbox_limit = <size_in_bytes> Took me ages to find this, no one seems to talk about it. ;) In the end if found it by invoking postconf and scanning for likely looking candidates.
    – ISparkes
    Dec 7, 2016 at 9:21
  • The default message size limit is 10240000 Bytes = 10 MB, not 50 MB
    – 黄雨伞
    Dec 20, 2016 at 18:52
  • 1
    @黄雨伞 - mailbox size and message size are different, and described in this answer differently
    – warren
    Jul 18, 2017 at 14:47
  • 1
    1) 2018. 2) Giving mail sizes in byte units. WTF. Nov 16, 2018 at 21:10
  • 2
    Yeah would nice if to able to do message_size_limit=15M (just a suggestion, don't try this)
    – Yetti99
    Sep 25, 2019 at 9:14
18

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
1
  • 2
    Example for setting the value: postconf -e message_size_limit=51200000
    – ESP32
    Apr 12 at 7:32
7

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?

6

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. ;)

3
  • 2
    Appreciate the comment - but this would be better as a suggested edit to the existing answer and/or as a comment on it :)
    – warren
    Dec 4, 2016 at 22:22
  • 2
    You are right, I moved it. Will delete this answer.
    – ISparkes
    Dec 7, 2016 at 9:38
  • you should delete this answer :)
    – warren
    Mar 16, 2018 at 14:10
1

For anyone looking for answer with recent versions of postfix(3+) , you should define message_size_limit to a number atleast 1.5 times higher then the actual message you want to send. Also this limit should be smaller then mailbox_size_limit.

For example if you want the clients/programs to be able to send a mail of atleast 30 MB in size, you have to set message_size_limit = 47185920 i.e 45 MB considering roughly a 1.5 times size increase(as the messages are transferred mime encoded and thus size increase by some factor), i.e 30 * 1.5 =45 MB(47185920 bytes) .

Note: This thread mentions the math required for mime-encoded expansion of message by a factor of 1.37. For safe side we can consider this 1.5 times.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .