If you are running your own mail server and send emails to your mailing list, you may have encountered “550 Mail Content Denied Error”. Some email service providers such as QQ mail don’t allow you to send a lot of emails to their users in a short amount of time. So if you found a 550 mail content denied error in your mail server log, you can limit the send frequency of your mail server.
This tutorial will show you how to achieve this rate limiting in postfix. As of version 2.5, postfix supports custom transports. Custom transports allow you to send email to a mail domain in a custom way.
First check your postfix version using the following command:
[email protected]:~$ sudo postconf mail_version mail_version = 2.11.3
You must upgrade your postfix if it’s older than 2.5.
Then edit your master.cf file:
sudo vi /etc/postfix/master.cf
add the following lines:
slow-email unix - - n - 1 smtp -o syslog_name=slow-email
slow-email is the new transport name, you can name whatever you like. Save your master.cf file.
Now add the following line to /etc/postfix/transport file. If no transport file exists, just create a new one. change domain.com to something like gmail.com or qq.com.
Save the transport file. And then create the corresponding db file using the following command:
sudo postmap /etc/postfix/transport
Open your main.cf file
sudo vi /etc/postfix main.cf
add the following lines to it:
transport_maps = hash:/etc/postfix/transport slow-email_destination_rate_delay = 12s slow-email_destination_concurrency_limit = 1 slow-email_destination_recipient_limit = 2 slow-email_initial_destination_concurrency=1
The first line will tell postfix to use your newly created transport table. The other lines define the send freqency. Replace slow-email with you own transport name.
- destination_rate_dealy defines the delay between each individual delivery. So if you set this to 12s, then postfix will send 60s/12s=5 deliveries.
- destination_concurrency_limit = 1 means ony one mail will be delivered once.
- destination_recipient_limit = 2 means there will be 2 recipients per mail delivery.
- And the last line set the initial number of parallel deliveries to 1.
Save your main.cf file and reload your postfix configuration.
sudo /etc/init.d/postfix reload
Next time you send email to that particular domain, you can check your /var/log/mail.log file to see how fast postfix is sending your email.