Advertisement
Guest User

Untitled

a guest
Jan 10th, 2017
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 1.96 KB | None | 0 0
  1. # i-MSCP Listener::Postfix::Transport::Table listener file
  2. # Copyright (C) 2017 Laurent Declercq <l.declercq@nuxwin.com>
  3. # Copyright (C) 2017 Matthew L. Hill <m.hill@innodapt.com>
  4. #
  5. #
  6. # This library is free software; you can redistribute it and/or
  7. # modify it under the terms of the GNU Lesser General Public
  8. # License as published by the Free Software Foundation; either
  9. # version 2.1 of the License, or (at your option) any later version.
  10. #
  11. # This library is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  14. # Lesser General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU Lesser General Public
  17. # License along with this library; if not, write to the Free Software
  18. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
  19.  
  20. package Listener::Postfix::Transport::Table;
  21.  
  22. #
  23. ## Allows to add entries in the postfix transport(5) table
  24. #
  25.  
  26. use strict;
  27. use warnings;
  28. use iMSCP::EventManager;
  29. use Servers::mta;
  30.  
  31. #
  32. ## Configuration variables
  33. #
  34.  
  35. # Parameter that allows to specify transport entries that must be added in the
  36. # Postfix transport(5) table.
  37. #
  38. # Please replace the entries below by your own entries.
  39. my %transportTableEntries = (
  40.     'recipientdomain.tld' => 'relay:my.smtprelay',
  41.     'user2@domain.tld'    => 'smtp:some-other-host'
  42. );
  43.  
  44. #
  45. ## Please, don't edit anything below this line
  46. #
  47.  
  48. # Listener responsible to add entries in the Postfix transport(5) table
  49. iMSCP::EventManager->getInstance()->register(
  50.     'afterCreatePostfixMaps',
  51.     sub {
  52.         my $mta = Servers::mta->factory();
  53.  
  54.         while(my ($recipient, $transport) = each(%transportTableEntries)) {
  55.             my $rs = $mta->addMapEntry( $mta->{'config'}->{'MTA_TRANSPORT_HASH'}, "$recipient\t$transport");
  56.             return $rs if $rs;
  57.         }
  58.  
  59.         0;
  60.     }
  61. );
  62.  
  63. 1;
  64. __END__
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement