Loading ...
Sorry, an error occurred while loading the content.
 

Delivering only specific mails locally

Expand Messages
  • Gerald Vogt
    Hi! Most of our servers are set up as null client and sent all through our mail relays. myhostname = hostname.example.com relayhost = $mydomain inet_interfaces
    Message 1 of 6 , Nov 16, 2012
      Hi!

      Most of our servers are set up as null client and sent all through our
      mail relays.

      myhostname = hostname.example.com
      relayhost = $mydomain
      inet_interfaces = loopback-only
      mydestination =

      However, I have one server which should work the same except for one
      specific mailbox which should be delivered locally, i.e. all mails go
      through the relayhost except one address (account or account@localhost
      or account@...).

      So far I haven't found a way how to do this except resetting
      mydestination to the default ($myhostname, localhost.$mydomain,
      localhost) and setting forwards for all other addresses except the
      account@ address.

      Is there any better way to do this? I.e.:

      1. deliver mails to account locally.
      2. forward all local mails for any other account to relayhost

      and ideally

      3. accept mails for account@... through smtp from remote
      4. reject any other email for any other address through smtp from remote.

      Thanks,

      Gerald
    • Noel Jones
      ... # main.cf mydestination = localhost virtual_alias_maps = hash:/etc/postfix/virtual # virtual account@example.com account@localhost ... # main.cf
      Message 2 of 6 , Nov 16, 2012
        On 11/16/2012 2:30 PM, Gerald Vogt wrote:
        > Hi!
        >
        > Most of our servers are set up as null client and sent all through our
        > mail relays.
        >
        > myhostname = hostname.example.com
        > relayhost = $mydomain
        > inet_interfaces = loopback-only
        > mydestination =
        >
        > However, I have one server which should work the same except for one
        > specific mailbox which should be delivered locally, i.e. all mails go
        > through the relayhost except one address (account or account@localhost
        > or account@...).
        >
        > So far I haven't found a way how to do this except resetting
        > mydestination to the default ($myhostname, localhost.$mydomain,
        > localhost) and setting forwards for all other addresses except the
        > account@ address.
        >
        > Is there any better way to do this? I.e.:
        >
        > 1. deliver mails to account locally.
        > 2. forward all local mails for any other account to relayhost

        # main.cf
        mydestination = localhost
        virtual_alias_maps = hash:/etc/postfix/virtual

        # virtual
        account@... account@localhost

        >
        > and ideally
        >
        > 3. accept mails for account@... through smtp from remote
        > 4. reject any other email for any other address through smtp from remote.


        # main.cf
        inet_interfaces = all
        smtpd_recipient_restrictions =
        check_recipient_access hash:/etc/postfix/recipients
        reject

        # recipients
        account@... OK



        References:
        http://www.postfix.org/documentation.html
        http://www.postfix.org/STANDARD_CONFIGURATION_README.html
        http://www.postfix.org/SMTPD_ACCESS_README.html


        -- Noel Jones
      • Gerald Vogt
        ... This doesn t work. Mails for account are still forwarded to the mail relay. Even if I add another line for account@hostname.example.com, account and
        Message 3 of 6 , Nov 16, 2012
          On Friday, November 16, 2012, Noel Jones wrote:
          On 11/16/2012 2:30 PM, Gerald Vogt wrote:

          > 1. deliver mails to account locally.
          > 2. forward all local mails for any other account to relayhost

          # main.cf
          mydestination = localhost
          virtual_alias_maps = hash:/etc/postfix/virtual

          # virtual
          account@...   account@localhost


          This doesn't work. Mails for account are still forwarded to the mail relay. Even if I add another line for account@..., account and account@... it won't be delivered locally.

          Gerald
        • /dev/rob0
          ... Probably should also have localhost.$mydomain there: http://www.postfix.org/postconf.5.html#append_dot_mydomain ... What is this
          Message 4 of 6 , Nov 16, 2012
            On Fri, Nov 16, 2012 at 11:29:35PM +0100, Gerald Vogt wrote:
            > On Friday, November 16, 2012, Noel Jones wrote:
            > > On 11/16/2012 2:30 PM, Gerald Vogt wrote:
            > >
            > > > 1. deliver mails to account locally.
            > > > 2. forward all local mails for any other account to relayhost
            > >
            > > # main.cf
            > > mydestination = localhost

            Probably should also have "localhost.$mydomain" there:

            http://www.postfix.org/postconf.5.html#append_dot_mydomain

            > > virtual_alias_maps = hash:/etc/postfix/virtual
            > >
            > > # virtual
            > > account@... <javascript:;> account@localhost

            What is this "<javascript:;>" garbage? Is that in the actual
            virtual(5) file, or just inserted by a silly MUA?

            > This doesn't work. Mails for account are still forwarded to
            > the mail relay. Even if I add another line for
            > account@..., account and
            > account@... it won't be delivered locally.

            It's probably time for you to show logs and postconf -n:

            http://www.postfix.org/DEBUG_README.html#mail
            --
            http://rob0.nodns4.us/ -- system administration and consulting
            Offlist GMX mail is seen only if "/dev/rob0" is in the Subject:
          • Gerald Vogt
            ... Thanks! That makes the difference. Now mail to the mailbox listed in virtual is delivered locally while other mails go through the relays. The only
            Message 5 of 6 , Nov 16, 2012
              On 16.11.12 23:40, /dev/rob0 wrote:
              > On Fri, Nov 16, 2012 at 11:29:35PM +0100, Gerald Vogt wrote:
              >> On Friday, November 16, 2012, Noel Jones wrote:
              >>> On 11/16/2012 2:30 PM, Gerald Vogt wrote:
              >>>
              >>>> 1. deliver mails to account locally.
              >>>> 2. forward all local mails for any other account to relayhost
              >>>
              >>> # main.cf
              >>> mydestination = localhost
              >
              > Probably should also have "localhost.$mydomain" there:
              >
              > http://www.postfix.org/postconf.5.html#append_dot_mydomain

              Thanks! That makes the difference. Now mail to the mailbox listed in
              virtual is delivered locally while other mails go through the relays.

              The only exception now is mails addressed specifically to @localhost,
              e.g. account2@localhost are also delivered locally.

              I guess I could live with that and see if anything accumulates in
              mailboxes except account. Or is there an easy way to prevent this, too?

              Now I have this:

              main.cf:
              alias_database = hash:/etc/aliases
              alias_maps = hash:/etc/aliases
              command_directory = /usr/sbin
              config_directory = /etc/postfix
              daemon_directory = /usr/libexec/postfix
              data_directory = /var/lib/postfix
              debug_peer_level = 2
              html_directory = no
              inet_interfaces = localhost
              inet_protocols = all
              mail_owner = postfix
              mailq_path = /usr/bin/mailq.postfix
              manpage_directory = /usr/share/man
              mydestination = localhost.$mydomain, localhost
              newaliases_path = /usr/bin/newaliases.postfix
              queue_directory = /var/spool/postfix
              readme_directory = /usr/share/doc/postfix-2.6.6/README_FILES
              relayhost = $mydomain
              sample_directory = /usr/share/doc/postfix-2.6.6/samples
              sendmail_path = /usr/sbin/sendmail.postfix
              setgid_group = postdrop
              unknown_local_recipient_reject_code = 550
              virtual_alias_maps = hash:/etc/postfix/virtual

              virtual:
              account account@localhost


              E-Mails on the server to

              account
              account@localhost
              account@hostname
              account@...
              account@...

              all are delivered locally. So are

              account2@localhost
              account2@...

              All other account2 receipients

              account2
              account2@hostname
              account2@...

              go through the relays.

              -Gerald
            • /dev/rob0
              ... If you want to specify only one address to deliver locally, you probably want a non-default setting of local_recipient_maps. For example: main.cf :
              Message 6 of 6 , Nov 17, 2012
                On Sat, Nov 17, 2012 at 07:05:28AM +0100, Gerald Vogt wrote:
                > The only exception now is mails addressed specifically to
                > @localhost, e.g. account2@localhost are also delivered locally.
                >
                > I guess I could live with that and see if anything accumulates
                > in mailboxes except account. Or is there an easy way to prevent
                > this, too?

                If you want to specify only one address to deliver locally, you
                probably want a non-default setting of local_recipient_maps. For
                example:


                main.cf :

                alias_maps = hash:/etc/aliases
                local_recipient_maps = $alias_maps

                /etc/aliases :

                # "account" is aliased to itself, or more specifically to
                # "account@$myorigin"
                account: account
                # You could leave the default aliases in place, possibly pointing
                # them to remote addresses if desired:
                [ ... ]
                root: gerald@...


                http://www.postfix.org/LOCAL_RECIPIENT_README.html
                http://www.postfix.org/postconf.5.html#local_recipient_maps
                --
                http://rob0.nodns4.us/ -- system administration and consulting
                Offlist GMX mail is seen only if "/dev/rob0" is in the Subject:
              Your message has been successfully submitted and would be delivered to recipients shortly.