Hi!
We currently uses the routing of e-mails through different internet links (multiples mx to send e-mails).
I use the script below for this purpose, that changes the parameter hostname of postfix, and in my firewall I rotate a source for output for a specific link)
/etc/postfix/random.pl
01 #!/usr/bin/perl -w
02 # author: Hari Hendaryanto <hari.h -at- csmcom.com>
03
04 use strict;
05 use warnings;
06 use Sys::Syslog qwDEFAULT setlogsock);
07
08 #
09 # our transports array, we will define this in master.cf as transport services
10 #
11
12 our @array = (
13 'rotate1:',
14 'rotate2:',
15 'rotate3:',
16 'rotate4:',
17 'rotate5:'
18 );
19
20 #
21 # Initalize and open syslog.
22 #
23 openlog('postfix/randomizer','pid','mail');
24
25 #
26 # Autoflush standard output.
27 #
28 select STDOUT; $|++;
29
30 while (<>) {
31 chomp;
32 # randomizing transports array
33 my $random_smtp = int(rand(scalar(@array)));
34 if (/^get\s(.+)$/i) {
35 print "200 $array[$random_smtp]\n";
36 syslog("info","Using: %s Transport Service", $random_smtp);
37 next;
38 }
39
40 print "200 smtp:";
41 }
/etc/postfix/master.cf
1 127.0.0.1:2527 inet n n n - 0 spawn
2 user=nobody argv=/etc/postfix/random.pl
01 # random smtp
02 rotate1 unix - - n - - smtp
03 -o syslog_name=postfix-rotate1
04 -o smtp_helo_name=smtp1.example.com
05 -o smtp_bind_address=1.2.3.1
06
07 rotate2 unix - - n - - smtp
08 -o syslog_name=postfix-rotate2
09 -o smtp_helo_name=smtp2.example.com
10 -o smtp_bind_address=1.2.3.2
11
12 rotate3 unix - - n - - smtp
13 -o syslog_name=postfix-rotate3
14 -o smtp_helo_name=smtp3.example.com
15 -o smtp_bind_address=1.2.3.3
16
17 rotate4 unix - - n - - smtp
18 -o syslog_name=postfix-rotate4
19 -o smtp_helo_name=smtp4.example.com
20 -o smtp_bind_address=1.2.3.4
21
22 rotate5 unix - - n - - smtp
23 -o syslog_name=postfix-rotate5
24 -o smtp_helo_name=smtp5.example.com
25 -o smtp_bind_address=1.2.3.5
main.cf
1 transport_maps = tcp:[127.0.0.1]:2527
2 127.0.0.1:2527_time_limit = 3600s
Is there via GUI this kind of configuration?
Is there any way I can modify the settings of main.cf and master.cf for this purpose? These extra settings will be lost when using GUI I save the settings or in case of update?
Thanks!
Rafael Carvalho
We currently uses the routing of e-mails through different internet links (multiples mx to send e-mails).
I use the script below for this purpose, that changes the parameter hostname of postfix, and in my firewall I rotate a source for output for a specific link)
/etc/postfix/random.pl
01 #!/usr/bin/perl -w
02 # author: Hari Hendaryanto <hari.h -at- csmcom.com>
03
04 use strict;
05 use warnings;
06 use Sys::Syslog qwDEFAULT setlogsock);
07
08 #
09 # our transports array, we will define this in master.cf as transport services
10 #
11
12 our @array = (
13 'rotate1:',
14 'rotate2:',
15 'rotate3:',
16 'rotate4:',
17 'rotate5:'
18 );
19
20 #
21 # Initalize and open syslog.
22 #
23 openlog('postfix/randomizer','pid','mail');
24
25 #
26 # Autoflush standard output.
27 #
28 select STDOUT; $|++;
29
30 while (<>) {
31 chomp;
32 # randomizing transports array
33 my $random_smtp = int(rand(scalar(@array)));
34 if (/^get\s(.+)$/i) {
35 print "200 $array[$random_smtp]\n";
36 syslog("info","Using: %s Transport Service", $random_smtp);
37 next;
38 }
39
40 print "200 smtp:";
41 }
/etc/postfix/master.cf
1 127.0.0.1:2527 inet n n n - 0 spawn
2 user=nobody argv=/etc/postfix/random.pl
01 # random smtp
02 rotate1 unix - - n - - smtp
03 -o syslog_name=postfix-rotate1
04 -o smtp_helo_name=smtp1.example.com
05 -o smtp_bind_address=1.2.3.1
06
07 rotate2 unix - - n - - smtp
08 -o syslog_name=postfix-rotate2
09 -o smtp_helo_name=smtp2.example.com
10 -o smtp_bind_address=1.2.3.2
11
12 rotate3 unix - - n - - smtp
13 -o syslog_name=postfix-rotate3
14 -o smtp_helo_name=smtp3.example.com
15 -o smtp_bind_address=1.2.3.3
16
17 rotate4 unix - - n - - smtp
18 -o syslog_name=postfix-rotate4
19 -o smtp_helo_name=smtp4.example.com
20 -o smtp_bind_address=1.2.3.4
21
22 rotate5 unix - - n - - smtp
23 -o syslog_name=postfix-rotate5
24 -o smtp_helo_name=smtp5.example.com
25 -o smtp_bind_address=1.2.3.5
main.cf
1 transport_maps = tcp:[127.0.0.1]:2527
2 127.0.0.1:2527_time_limit = 3600s
Is there via GUI this kind of configuration?
Is there any way I can modify the settings of main.cf and master.cf for this purpose? These extra settings will be lost when using GUI I save the settings or in case of update?
Thanks!
Rafael Carvalho