How to change the maximum mail size in Postfix

Better Stack Team
Updated on December 21, 2023

To change the maximum mail size in Postfix, you need to modify the configuration settings for Postfix. The maximum mail size is controlled by two main parameters: message_size_limit and mailbox_size_limit. Here's how you can change these settings:

Edit the Postfix Configuration File

Open the Postfix main configuration file in your preferred text editor. The location of this file can vary depending on your system, but common locations are /etc/postfix/main.cf or /etc/postfix/master.cf. You may need superuser privileges to edit this file, so use sudo or su if necessary.

 
sudo nano /etc/postfix/main.cf

Adjust the message_size_limit

To change the maximum allowed size of an individual email message, locate and modify the message_size_limit parameter. The value should be specified in bytes. For example, to set the limit to 20MB, you can use:

 
message_size_limit = 20971520

This sets the message size limit to 20 * 1024 * 1024 bytes.

Adjust the mailbox_size_limit (Optional)

The mailbox_size_limit parameter controls the maximum size of a user's mailbox. You can also adjust this parameter if you want to limit the mailbox size. To set a 2GB limit, for instance, use:

 
mailbox_size_limit = 2147483648

Save the Configuration File

Save your changes and exit the text editor.

Reload Postfix

After making these changes, you need to reload the Postfix configuration to apply the new settings:

 
sudo postfix reload

Test the Configuration

You should test your configuration to ensure that it's working as expected. Send an email with an attachment that is larger than your specified message size limit to see if it gets rejected or accepted.

Keep in mind that adjusting these limits should be done carefully. Setting overly large values may lead to resource utilization issues, while setting too low limits may cause legitimate emails to be rejected. Choose the limits based on your system's capacity and your specific use case. Additionally, consider the potential impact on both sending and receiving mail servers when making changes to message size limits.

Make your mark

Join the writer's program

Are you a developer and love writing and sharing your knowledge with the world? Join our guest writing program and get paid for writing amazing technical guides. We'll get them to the right readers that will appreciate them.

Write for us
Writer of the month
Marin Bezhanov
Marin is a software engineer and architect with a broad range of experience working...
Build on top of Better Stack

Write a script, app or project on top of Better Stack and share it with the world. Make a public repository and share it with us at our email.

community@betterstack.com

or submit a pull request and help us build better products for everyone.

See the full list of amazing projects on github