How To Configure Custom Postfix Bounce Messages
How To Configure Custom Postfix Bounce MessagesVersion 1.0 Since Postfix version 2.3, Postfix supports custom bounce messages. This guide shows how to configure custom Postfix bounce messages. I do not issue any guarantee that this will work for you!
1 Postfix VersionFirst you should find out about your Postfix version to make sure it supports custom bounce messages: postconf -d | grep mail_version server2:~# postconf -d | grep mail_version If your Postfix is 2.3 or newer, then you're good to go.
2 Set maximal_queue_lifetime And delay_warning_timeFrom http://www.postfix.org/postconf.5.html: maximal_queue_lifetime: The maximal time a message is queued before it is sent back as undeliverable. delay_warning_time: The time after which the sender receives the message headers of mail that is still queued. The postconf -n command shows the settings that are currently configured in /etc/postfix/main.cf, whereas the postconf -d command shows the default settings that are valid unless something else is set in /etc/postfix/main.cf. To find out about the current value of maximal_queue_lifetime, you can run postconf -d | grep maximal_queue_lifetime If postconf -n doesn't display anything, this means the value from postconf -d is currently being used: server2:~# postconf -d | grep maximal_queue_lifetime The same goes for delay_warning_time: postconf -d | grep delay_warning_time server2:~# postconf -d | grep delay_warning_time If you want to modify these settings, you can use the postconf -e command. It will write the settings to /etc/postfix/main.cf, e.g. like this: postconf -e 'maximal_queue_lifetime = 1d' Restart Postfix afterwards: /etc/init.d/postfix restart The reason that we care about these two settings is that their values can be used in the custom bounce messages.
3 Create A Custom Bounce MessageFrom http://www.postfix.org/bounce.5.html: The template file can specify templates for failed mail, delayed mail, successful delivery or for address verification. These templates are named failure_template, delay_template, success_template and verify_template, respectively. You can but do not have to specify all four templates in a bounce template file. Each template starts with "template_name = <<EOF" and ends with a line that contains the word "EOF" We can now create the file /etc/postfix/bounce.cf which contains the templates like this (I'm using all four templates here, but you can leave out the ones you don't need). It is absolutely important that the file ends with an empty line! vi /etc/postfix/bounce.cf
You can customize the messages to your likings. In the messages, you can use all main.cf variables (e.g. $myhostname). If you take a look at the delay_template, you'll see that I use the additional variables $delay_warning_time_hours and $maximal_queue_lifetime_days. You could as well use $delay_warning_time_seconds, $delay_warning_time_minutes, $delay_warning_time_days, $delay_warning_time_weekes resp. $maximal_queue_lifetime_seconds, $maximal_queue_lifetime_minutes, $maximal_queue_lifetime_hours, $maximal_queue_lifetime_weeks, but keep in mind what http://www.postfix.org/bounce.5.html explains about these variables: delay_warning_time_suffix: Expands into the value of the delay_warning_time parameter, expressed in the time unit specified by suffix, which is one of seconds, minutes, hours, days, or weeks. maximal_queue_lifetime_suffix: Expands into the value of the maximal_queue_lifetime parameter, expressed in the time unit specified by suffix. See above under delay_warning_time for possible suffix values. So if you use the variable $delay_warning_time_minutes instead of $delay_warning_time_hours in your template, you should follow it by the word "minutes" instead of "hours". Next we configure Postfix to use the custom templates: postconf -e 'bounce_template_file = /etc/postfix/bounce.cf' To check what the templates look like when all variables are replaced with their real values, and to make sure that there are no errors in your templates (e.g. like a missing newline at the end of /etc/postfix/bounce.cf), run: postconf -b /etc/postfix/bounce.cf server2:~# postconf -b /etc/postfix/bounce.cf If no errors are shown, we can restart Postfix so that it can use the custom templates: /etc/init.d/postfix restart
4 Links
|
www.seamlessenterprise.com
One number. One voicemail. Seize the lead. Sprint Mobile Integration.
www.seamlessenterprise.com
One Number. One Voicemail.
Make it easier for clients to reach you. Turn your desk phone and mobile phone into one with Sprint Mobile Integration.
www.seamlessenterprise.com
One number. One voicemail. Sprint Mobile Integration.
www.seamlessenterprise.com
AT&T Synaptic Compute as a Service. Boost your power on demand.
Trial: IBM Cognos Express Reporting, Analysis & Planning







Recent comments
15 hours 2 min ago
17 hours 3 min ago
20 hours 14 min ago
22 hours 33 min ago
23 hours 43 min ago
1 day 1 hour ago
1 day 5 hours ago
1 day 8 hours ago
1 day 8 hours ago
1 day 23 hours ago