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

How to relay subdomain but deliver local mail?

Expand Messages
  • Andrew Stuart
    I want mail to example.org to be delivered to the local virtual mailboxes. I want mail to in.example.org to be relayed to mail.power.com. The configuration
    Message 1 of 7 , Jun 3, 2014
    • 0 Attachment
      I want mail to example.org to be delivered to the local virtual
      mailboxes. I want mail to in.example.org to be relayed to
      mail.power.com.

      The configuration below is relaying all mail to mail.power.com.

      Can someone please suggest what I need to do to fix?
      thanks




      # See /usr/share/postfix/main.cf.dist for a commented, more
      complete version


      # Debian specific: Specifying a file name will cause the first
      # line of that file to be used as the name. The Debian default
      # is /etc/mailname.
      #myorigin = /etc/mailname

      smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
      biff = no

      # appending .domain is the MUA's job.
      append_dot_mydomain = no

      # Uncomment the next line to generate "delayed mail" warnings
      #delay_warning_time = 4h

      readme_directory = no

      # TLS parameters
      smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
      smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
      smtpd_use_tls=yes
      smtpd_tls_session_cache_database = btree:${data_directory}/
      smtpd_scache
      smtp_tls_session_cache_database = btree:${data_directory}/
      smtp_scache

      # See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc
      package for
      # information on enabling SSL in the smtp client.
      transport_maps = hash:/etc/postfix/transport

      #virtual_mailbox_limit = 2000000000
      #virtual_mailbox_domains = example.org
      home_mailbox = Maildir/
      virtual_alias_maps = hash:/etc/postfix/virtual.aliases
      virtual_gid_maps = static:5000
      virtual_mailbox_base = /home/vmail
      virtual_mailbox_maps = hash:/etc/postfix/vmaps
      virtual_minimum_uid = 100
      virtual_uid_maps = static:5000
      parent_domain_matches_subdomains = smtpd_access_maps
      relay_domains = in.example.org
      local_transport = virtual
      local_recipient_maps = $virtual_mailbox_maps

      smtpd_relay_restrictions = permit_mynetworks
      permit_sasl_authenticated defer_unauth_destination
      myhostname = mail.example.org
      alias_maps = hash:/etc/aliases
      alias_database = hash:/etc/aliases
      myorigin = /etc/mailname
      mydestination = example.org, localhost.example.org, localhost
      relayhost = mail.power.com
      mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
      mailbox_size_limit = 0
      recipient_delimiter = +
      inet_interfaces = all
      message_size_limit = 5240000
    • Viktor Dukhovni
      ... Try postconf -n instead of cut/paste from main.cf. -- Viktor.
      Message 2 of 7 , Jun 3, 2014
      • 0 Attachment
        On Wed, Jun 04, 2014 at 11:39:56AM +1000, Andrew Stuart wrote:
        > I want mail to example.org to be delivered to the local virtual mailboxes. I
        > want mail to in.example.org to be relayed to mail.power.com.
        >
        > The configuration below is relaying all mail to mail.power.com.

        Try "postconf -n" instead of cut/paste from main.cf.

        --
        Viktor.
      • Andrew Stuart
        postconf -n output alias_database = hash:/etc/aliases alias_maps = hash:/etc/aliases append_dot_mydomain = no biff = no config_directory = /etc/postfix
        Message 3 of 7 , Jun 3, 2014
        • 0 Attachment
          postconf -n output

          alias_database = hash:/etc/aliases
          alias_maps = hash:/etc/aliases
          append_dot_mydomain = no
          biff = no
          config_directory = /etc/postfix
          home_mailbox = Maildir/
          inet_interfaces = all
          local_recipient_maps = $virtual_mailbox_maps
          local_transport = virtual
          mailbox_size_limit = 0
          message_size_limit = 5240000
          mydestination = example.org, localhost.example.org, localhost
          myhostname = mail.example.org
          mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
          myorigin = /etc/mailname
          parent_domain_matches_subdomains = smtpd_access_maps
          readme_directory = no
          recipient_delimiter = +
          relay_domains = in.example.org
          relayhost = mail.power.com
          smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
          smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
          smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated
          defer_unauth_destination
          smtpd_tls_cert_file = /etc/ssl/certs/ssl-cert-snakeoil.pem
          smtpd_tls_key_file = /etc/ssl/private/ssl-cert-snakeoil.key
          smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
          smtpd_use_tls = yes
          transport_maps = hash:/etc/postfix/transport
          virtual_alias_maps = hash:/etc/postfix/virtual.aliases
          virtual_gid_maps = static:5000
          virtual_mailbox_base = /home/vmail
          virtual_mailbox_maps = hash:/etc/postfix/vmaps
          virtual_minimum_uid = 100
          virtual_uid_maps = static:5000

          On 04/06/2014, at 11:49 AM, Viktor Dukhovni wrote:

          On Wed, Jun 04, 2014 at 11:39:56AM +1000, Andrew Stuart wrote:
          > I want mail to example.org to be delivered to the local virtual
          > mailboxes. I
          > want mail to in.example.org to be relayed to mail.power.com.
          >
          > The configuration below is relaying all mail to mail.power.com.

          Try "postconf -n" instead of cut/paste from main.cf.

          --
          Viktor.
        • Viktor Dukhovni
          ... Only applicable with local(8) delivery, but you have local_transport = virtual, so unless you have explicit transport entries selecting local , these can
          Message 4 of 7 , Jun 3, 2014
          • 0 Attachment
            On Wed, Jun 04, 2014 at 11:52:59AM +1000, Andrew Stuart wrote:

            > alias_database = hash:/etc/aliases
            > alias_maps = hash:/etc/aliases
            > home_mailbox = Maildir/

            Only applicable with local(8) delivery, but you have
            local_transport = virtual, so unless you have explicit
            transport entries selecting "local", these can be set
            empty.

            > local_recipient_maps = $virtual_mailbox_maps
            > local_transport = virtual
            > mydestination = example.org, localhost.example.org, localhost

            So example.org users should be routed to virtual(8) barring
            transport overrides.

            > relay_domains = in.example.org
            > relayhost = mail.power.com

            This domain should be routed to the "relay" transport barring
            transport overrides, with a nexthop of $relayhost.

            > smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated
            > defer_unauth_destination

            Change defer to reject when you get a chance.

            > smtpd_tls_cert_file = /etc/ssl/certs/ssl-cert-snakeoil.pem
            > smtpd_tls_key_file = /etc/ssl/private/ssl-cert-snakeoil.key

            http://www.postfix.org/TLS_README.html#quick-start

            > smtpd_use_tls = yes

            smtpd_tls_security_level = may

            > transport_maps = hash:/etc/postfix/transport

            What's in there relating to either domain or a "*"
            entry?

            > virtual_alias_maps = hash:/etc/postfix/virtual.aliases

            Are addresses in example.org rewritten to some other domain?
            Log entries of mail leaving via relayhost?

            --
            Viktor.
          • Andrew Stuart
            transport file contains: * smtp:mail.power.com On 04/06/2014, at 11:59 AM, Viktor Dukhovni wrote: ... Only applicable with local(8) delivery, but
            Message 5 of 7 , Jun 3, 2014
            • 0 Attachment
              transport file contains:

              * smtp:mail.power.com

              On 04/06/2014, at 11:59 AM, Viktor Dukhovni wrote:

              On Wed, Jun 04, 2014 at 11:52:59AM +1000, Andrew Stuart wrote:

              > alias_database = hash:/etc/aliases
              > alias_maps = hash:/etc/aliases
              > home_mailbox = Maildir/

              Only applicable with local(8) delivery, but you have
              local_transport = virtual, so unless you have explicit
              transport entries selecting "local", these can be set
              empty.

              > local_recipient_maps = $virtual_mailbox_maps
              > local_transport = virtual
              > mydestination = example.org, localhost.example.org, localhost

              So example.org users should be routed to virtual(8) barring
              transport overrides.

              > relay_domains = in.example.org
              > relayhost = mail.power.com

              This domain should be routed to the "relay" transport barring
              transport overrides, with a nexthop of $relayhost.

              > smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated
              > defer_unauth_destination

              Change defer to reject when you get a chance.

              > smtpd_tls_cert_file = /etc/ssl/certs/ssl-cert-snakeoil.pem
              > smtpd_tls_key_file = /etc/ssl/private/ssl-cert-snakeoil.key

              http://www.postfix.org/TLS_README.html#quick-start

              > smtpd_use_tls = yes

              smtpd_tls_security_level = may

              > transport_maps = hash:/etc/postfix/transport

              What's in there relating to either domain or a "*"
              entry?

              > virtual_alias_maps = hash:/etc/postfix/virtual.aliases

              Are addresses in example.org rewritten to some other domain?
              Log entries of mail leaving via relayhost?

              --
              Viktor.
            • Viktor Dukhovni
              ... And you re surprised why everything is going via smtp to mail.power.com? -- Viktor.
              Message 6 of 7 , Jun 3, 2014
              • 0 Attachment
                On Wed, Jun 04, 2014 at 12:16:08PM +1000, Andrew Stuart wrote:

                > transport file contains:
                >
                > * smtp:mail.power.com

                And you're surprised why everything is going via smtp to mail.power.com?

                --
                Viktor.
              • Andrew Stuart
                Not since you pointed it out. Thanks Viktor works fine now. On 04/06/2014, at 12:17 PM, Viktor Dukhovni wrote: ... And you re surprised why everything is going
                Message 7 of 7 , Jun 3, 2014
                • 0 Attachment
                  Not since you pointed it out.

                  Thanks Viktor works fine now.

                  On 04/06/2014, at 12:17 PM, Viktor Dukhovni wrote:

                  On Wed, Jun 04, 2014 at 12:16:08PM +1000, Andrew Stuart wrote:

                  > transport file contains:
                  >
                  > * smtp:mail.power.com

                  And you're surprised why everything is going via smtp to mail.power.com?

                  --
                  Viktor.
                Your message has been successfully submitted and would be delivered to recipients shortly.